问题
I have worked with selenium for like 3 months. My tests worked fine in Firefox 3.6. However, when I update to Firefox 4 and selenium-server 2.0b3, there is a problem with the confirmation dialog.
Here is the code (very simple):
choose_ok_on_next_confirmation
click("delete_button")
get_confirmation
wait_for_page_to_load
I have searched a lot and tried many other things like assert_confirmation or store_confirmation. Even is_confirmation_present
didn't work. They can't detect the dialog I think.
I downgraded to firefox 3.6 and it worked fine.
Anybody know the reason? I don't know much about how Firefox 4 work. And I still have to explain this problem to my partner.
回答1:
Yes, there are several comments in Selenium issue tracker that confirm this problem -- http://code.google.com/p/selenium/issues/detail?id=27 , and my own experience shows the same.
The reason of this issue is not a specific Selenium version, it is probably related to some changes in Firefox 4 dialog mechanics, older Seleniums of 1.x series don't work too.
At the moment, you have two ways to go:
- downgrade to an earlier version of Firefox,
- migrate to a new Selenium 2.0 API (aka WebDriver)
WebDriver works with FF4, but still have problems with handling alerts and prompts issued from iframes. And of course it is still beta so there would be risky to switch to it, your partner may not like this either ;)
回答2:
page.evaluate_script('window.confirm = function(){
return true;
}')
works
来源:https://stackoverflow.com/questions/5602392/firefox-4-confirmation-dialog-in-selenium-2-0b3