Selenium SelectWindow command not working

The Selenium Select Window command fails and displays "Could not find window with title ...". but if I execute the Select Window command myself, it passes case and checks the elements.

The code I used:

public void testDefaultlogo() throws Exception { selenium.open("http://Sitename/samp.aspx"); selenium.type("ctl00_mainContentPlaceHolder_txt_LoginName", "uname"); selenium.type("ctl00_mainContentPlaceHolder_txt_Password", " pwd@12 "); selenium.click("ctl00_mainContentPlaceHolder_btn_login"); selenium.waitForPageToLoad("60000"); selenium.click("ctl00_defaultLogo"); selenium.selectWindow("Sample~Window-ID"); verifyEquals("http://Sitename/index.html", selenium.getLocation()); selenium.close(); selenium.selectWindow ("null"); verifyTrue(selenium.isElementPresent("ctl00_defaultLogo")); 

I mean, by clicking on one of the follwing commands in the Selenium IDE, it shows a green color, but if I run this case, it didn’t work and shows, as I mentioned above

+4
source share
2 answers

What I can get from your code is that when I click "ctl00_defaultLogo" another window will appear. A possible problem may be that after writing the selenium.click("ctl00_defaultLogo") command selenium.click("ctl00_defaultLogo") you need to wait for the popup to load.

Possible resolution, paste the command

 selenium.WaitForPopUp("Sample~Window-ID", "5000"); 

front

 selenium.selectWindow("Sample~Window-ID"); 

This will cause selenium to wait 5 seconds before choosing a popup.

Hope this helps !!!

0
source

It may not work several times in order to use it better.

 open_window("URL","WindowID or title or name"); selenium.selectWindow("WindowID or title or name"); 
0
source

Source: https://habr.com/ru/post/1333790/


All Articles