5

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

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
user1303594
  • 103
  • 1
  • 3
  • 10

2 Answers2

6

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

Nam G VU
  • 33,193
  • 69
  • 233
  • 372
CosminO
  • 5,018
  • 6
  • 28
  • 50
0

For the Selenium RC API, you need to use the SelectWindow command to switch to the pop-up window. The window can be specified either by its name (as specified on the JavaScript window.open() function) or its title. To switch back to the main window, use SelectWindow(None).

Ross Patterson
  • 9,527
  • 33
  • 48