views:

39

answers:

2

I'm working with selenium. while trying to click a button it creates a pop up (alert) and doesn’t return a page object. Because of that I can’t use “click” alone as this method expects a page object and eventually fails because of a timeout. I can use the “chooseOkOnNextConfirmation()” but this will click the pop up and i also want to verify that the pop up actually appeared. Is there any method that will click and verify this alert?

+1  A: 

for an alert you will need to use either

getAlert() call which will click ok on the alert. It will return the text in the alert as well so you can check its the alert that you want.

so an example would be

self.assertEqual("An alert",selenium.get_alert());
AutomatedTester
A: 

as far as I know you have to use always in alerts

selenium.get_confirmation()

from python doc: If an confirmation is generated but you do not consume it with getConfirmation, the next Selenium action will fail.

Dan