Firefox 4 confirmation dialog in selenium 2.0b3

為{幸葍}努か 提交于 2019-12-02 10:54:34

问题


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:

  1. downgrade to an earlier version of Firefox,
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!