我创建了一个将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
来重置警报的状态,但它引发了异常。
有没有办法完全重置浏览器对象的状态?