How to Handle HTML Windows in ASM Scenarios

Using selectWindow in ASM

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.

Selecting Windows with Titles

Step

Screenshot

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.

Selecting Windows with href Storing

Step

Screenshot

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 | test.”

    • Where “target” is whatever the target is for the field/button that opens the window.

 

To use this stored data, all you need to do is write the command open | ${test}. The window will be opened in the current tab you are in, meaning you don’t need to switch between tabs.

  • Do keep in mind, though, that you’re unable to go back to the previous site unless you store the previous address to a variable as well.

Selecting Windows with the Same Names

Step

Screenshot

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.

 

 

Can't find what you're looking for? Send an E-mail to support@apica.io