Selenium – How to select window if window do not have title or name

Selecting new opened window using “selectWindow” command in selenium IDE is very easy if new window has title or name. Click here to view example of “selectWindow” command with title as a target. If window has title then we can add it’s title in target field with “selectWindow” command and this way selenium

can identify window. But how to handle window which has not any title? Let we consider one scenario for such case. Supposing I am clicking on hyper link and opening new window. New window has not any title and I want to select that window to perform some actions on newly opened window using selenium IDE. How can I do it?

“storeAttribute” command will help us to handle this scenario. look at bellow given example.
(Note : Please set Block Pop-up windows = false before running this test case case. Otherwise bellow given script will not run properly.)

Example of how to handle window without title or name or id in selenium

New Test
Command Target Value
open http://only-testing-blog.blogspot.com/2013/09/testing.html
click link=Visit MyTest Page
storeAttribute link=Visit MyTest Page@target window1
selectWindow ${window1}
waitForElementPresent name=fname
pause 2000
highlight name=fname
type name=fname 1st time visit
of window1
selectWindow null
click link=Visit Testing Page
storeAttribute link=Visit Testing Page@target window2
selectWindow ${window2}
waitForElementPresent name=vehicle
pause 2000
highlight name=vehicle
click name=vehicle
selectWindow ${window1}
pause 2000
highlight name=fname
type name=fname 2nd time visit
of window1
pause 2000
selectWindow ${window2}
pause 2000
highlight name=gender
click name=gender
selectWindow ${window1}
close
selectWindow ${window2}
close

Above script is very long so full script description is very lengthy. Let me tell you main commands. 1st of all, i have not used window title or name id to select window. So please consider that new window has not any title or name. I have used ${window1} and ${window2} to select newly opened windows.${window1} and ${window2} are derived from “storeAttribute” command and this way every time, selenium will find targeted window.

One thought on “Selenium – How to select window if window do not have title or name

Leave a Reply

Your email address will not be published. Required fields are marked *