How to Handle HTML Windows in ASM Scenarios
Was this helpful?
Selenium IDE classic (2.9.1) and Selenium IDE TNG (3.0+) handle windows differently. So, if you use the newer Selenium version available for Chrome, you'll need to edit your selectWindow commands manually.
Selenium IDE v3+ uses handlers to check which tabs it’s on.
In the classic version of Selenium, you select the windows with the page title or store the URL of the window.
Selenium Classic can’t select windows that itself didn’t open. So windows that a script opened itself, for example, can’t be found. While this is rare, that might explain why you can’t select those windows.
Step
Screenshot
Create a script that opens a window.
Grab the name of the newly opened window by inspecting the page source:
Add a pause before selecting the window to make sure it’s actually loaded in the correct title. There’s currently no way to wait for a window to finish loading before selecting it.
Add a selectWindow with a target of the title of the page as the following picture shows:
To deselect the current window, repeat the above steps for the new/old window you want to select.
Step
Screenshot
Go to the page with a window and make sure it also has an href attached to it with a URL.
Write the command “storeAttribute
target@href
Step
Screenshot
Make sure you’re on the window you want to switch from.
Write the command “runScript
document.title = “Whatever the new title of the page is”
In Step 5 in the above example, I’ve also stored the previous name to prove that it changes the title.
As you can see above from the output log, Step 8 echoes the variable “test,” and step 9 echoes the variable “test1”:
Do steps 2-4 of the guide “Selecting Windows with Titles” to select the window you want to select.
Was this helpful?
Was this helpful?