gpt4 book ai didi

Watir:在手动关闭警报后尝试刷新页面时抛出 "unexpected alert open"错误

转载 作者:行者123 更新时间:2023-12-04 14:46:15 24 4
gpt4 key购买 nike

我创建了一个 Watir::Browser 的实例将 chrome 设置为浏览器。

b = Watir::Browser.new :chrome    

如果我 手动 关闭警报,然后尝试使用刷新页面
b.refresh

抛出以下错误:
Selenium::WebDriver::Error::UnhandledAlertError: unexpected alert open
(Session info: chrome=28.0.1500.95)
(Driver info: chromedriver=2.2,platform=Windows NT 6.1 x86_64)
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/response.rb:51:in assert_ok'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/response.rb:15:in initialize'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:59:in new'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:59:in create_response'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/default.rb:66:in request'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/http/common.rb:40:in call'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:634:in raw_execute'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:612:in execute'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/remote/bridge.rb:210:in refresh'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.35.0/lib/selenium/webdriver/common/navigation.rb:38:in refresh'
from C:/ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:201:in refresh'

当我打电话时 b.alert.exists?它返回 true .

我试着看使用 b.alert.initialize重置警报的状态,但会引发异常。

有没有办法完全重置浏览器对象的状态?

最佳答案

我也面临这个问题:

但是我通过将它放入 begin-rescue 成功摆脱了它堵塞。

方法如下:

  begin
# put line of code which triggers alert on page
rescue Selenium::WebDriver::Error::UnhandledAlertError
@browser.alert.ok
end

关于Watir:在手动关闭警报后尝试刷新页面时抛出 "unexpected alert open"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18461882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com