ocornut / ocornut/imgui_test_engine
Clicking on popup elements
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 629
- Forks
- 83
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the popup-related tests and comparing SetRef, ItemClick, PopupGetWindowID, and GetWindowByRef in the reported sequence. Done means clarifying whether Popup/Close is a supported reference path and documenting the intended way to target popup elements without using //$FOCUSED.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- testing
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100