点击此标签时:
<label> Row </label>
使用此Watir代码
br.frame(:name, "frameset").frame(:name, "main_content").span(:class=>"tabtext", :text=>/Row/).click
会打开一个新的浏览器窗口,但是收到以下错误消息:
Timeout::Error: Timeout::Error
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:745:in `start'
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/default.rb:81:in `response_for'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/default.rb:43:in `request'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:590:in `raw_execute'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:568:in `execute'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/remote/bridge.rb:350:in `clickElement'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/selenium-webdriver-2.19.0/lib/selenium/webdriver/common/element.rb:34:in `click'
from /Users/zeljko/.rvm/gems/ruby-1.9.3-p0/gems/watir-webdriver-0.5.3/lib/watir-webdriver/elements/element.rb:107:in `click'
from (irb):75
from /Users/zeljko/.rvm/rubies/ruby-1.9.3-p0/bin/irb:16:in `<main>'
在任何浏览器窗口中我都没有看到任何奇怪的内容。新窗口打开得很快。我不知道为什么会出现超时错误。我有什么办法可以摆脱它吗?或者页面只是为了缓慢响应?
如果我解除了异常,我可以关闭新窗口并继续编写脚本,但我想避免挽救错误。
环境:Mac OS X 10.7.3,Firefox 10.0.1,ruby 1.9.3p0,selenium-webdriver 2.19.0,watir-webdriver 0.5.3
更新
我很确定问题是由window.showModalDialog
打开的窗口引起的。例如,这次超时:
b.execute_script "window.showModalDialog('http://google.com');"
我会调查更多并更新问题。看起来Selenium尚未支持window.showModalDialog
:http://code.google.com/p/selenium/issues/detail?id=284
答案 0 :(得分:0)
由于您点击了一个跨度,这通常不会响应基本HTML中的点击,因此我怀疑是否有某种类型的javascript代码正在响应,或许它会看到onclick事件。
您是否尝试过使用.fire_event('onclick')
代替.click
来查看是否仍然会调用打开新页面但避免超时的代码?