Selenium: Testing pop-up windows

html, python, selenium

Solution

There is a property called switch_to

Q: How do I handle pop up windows?

A: WebDriver offers the ability to cope with multiple windows. This is done by using the `WebDriver.switch_to.window(knownName)` method to switch to a window with a known name.

If the name is not known, you can use `WebDriver.window_handles` to obtain a list of known windows.

You may pass the handle to `switch_to.window(handleName)`

For example I used `driverName.switchTo.window(driverName.getWindowHandle())` to get a hold of popups for which I didn't want to look for names.

Additional references: http://code.google.com/p/selenium/wiki/FrequentlyAskedQuestions

Problem

I have an issue when trying to test a web application with Selenium/Python. Basically I can't test elements of a pop-up window. A scenario: I can test all elements for a page. But when I go to click on a button that opens up a small pop up box I can't test the elements on the popup. It's like the pop up isn't in focus or active. I can test elements on the next page. For example click a button, brings me on to next page, and I can work with elements on the 'next' page. So it the problem seems to be popup specific. I could post code but to be honest it might confuse at this stage. I may post code in a later post, thanks

Original source

Related problems