Skip to content

Clicking on popup elements #84

@WhatWhatz

Description

@WhatWhatz

Hi pretty new to this project.
Got a small question:
I want to click on the Close Button that is part of a Popup described as follow

ImGui::Begin("Test", nullptr, ImGuiWindowFlags_NoSavedSettings);
ImGui::Text("Hello, automation world");
if (ImGui::Button("Open")) ImGui::OpenPopup("Popup");

if (ImGui::BeginPopup("Popup"))
{
    ImGui::Text("This is text in popup");

    if (ImGui::Button("Close")) ImGui::CloseCurrentPopup();

    ImGui::EndPopup();
}
ImGui::End();

To emulate a click I intuitively wrote the following:

ctx->SetRef("Test");
ctx->ItemClick("Open");
ctx->Sleep(1);
ctx->ItemClick("Popup/Close");

However, this throws that '//Test/Popup/Close' is not a valid path
I don t want to use the //$FOCUSED as I want to make my test case as clear as possible

I checked how Popups are tested in the suite and found the following solution:

ctx->SetRef("Test");
ctx->ItemClick("Open");
ctx->Sleep(1);
ImGuiWindow* popup = NULL;
popup = ctx->GetWindowByRef(ctx->PopupGetWindowID("//Test/Popup"));
ctx->SetRef(popup->Name);
ctx->ItemClick("Close")

I understand that popup->Name is //Test/Popup_[numbers] but why this behavior? Why does ctx->SetRef(//Test/Popup); not refence the popup but ctx->PopupGetWindowID("//Test/Popup") points to it?
Am I using the first example incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions