我试图执行一个简单的浏览器测试
require 'rubygems'
require 'watir-webdriver'
b = Watir::Browser.new :firefox
b.goto 'http://www.google.com/'
浏览器立即启动并关闭,引发以下错误
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
from c:/ruby22/lib/ruby/2.2.0/net/http/request.rb:14:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new_request_for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:88:in `request'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:123:in `create_session'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:55:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:3:in `new'
from test.rb:3:in `<main>'
HTTP请求路径为空意味着什么?新版本的watir是否更改了调用参数?
有人遇到过类似的问题吗?
我的系统是Windows 7 64位,我运行在一个代理之后,浏览器已经配置了一个代理
---编辑---
我引入了一个尾随斜杠,但我现在得到了一个新的错误,也得到了以前的错误,每次我都要更改代码并保存它来获得这个错误
c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
from test.rb:8:in `new'
from test.rb:8:in `<main>'
---编辑---
我已经下载了geckodriver
v0。10.0
fromhttps://github.com/mozilla/geckodriver/releases然后复制粘贴了壁虎河。exe
,并将firefox文件夹添加到路径中
我安装了selenium-webDrive
测试版3.0.0.beta2.1
但我还是得到了同样的错误
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
我也尝试过安装火狐ESR版本,并添加到PATH,这也不起作用
---编辑---
我打开了文件c:/ruby22/lib/ruby/2.2.0/net/超文本传输协议/generic_request.rb
并介绍了打印声明如下
print "\n"
print uri_or_path
if URI === uri_or_path then
print "\ncoming to if part\n"
@uri = uri_or_path.dup
host = @uri.hostname.dup
host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
@path = uri_or_path.request_uri
raise ArgumentError, "no HTTP request path given" unless @path
else
print "\ncoming to else part\n"
@uri = nil
host = nil
raise ArgumentError, "no HTTP request path given" unless uri_or_path
raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
@path = uri_or_path.dup
end
我得到了下面的输出
/session
coming to else part
coming to else part
/shutdown
coming to else part
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:29:in `initialize': HTTP request path is empty (ArgumentError)
很可能是因为Firefox 47.0中的一个bug。您需要更新到Firefox 47.0.1,才能使用Selenium 2.53.4。
试着在IRB中输入这些命令,一次一行。这将使失败发生的地方更清楚
您最初的错误表明它在第3行失败,在上面的代码中,它尝试创建浏览器对象的新实例(该实例还启动firefox,然后尝试将浏览器对象连接到实际浏览器)。如果这不起作用,通常是因为您没有使用支持浏览器的webdriver版本。也许你有一个全新的firefox,需要更新webdriver。
有时,在一个新的FF发布后(每6周一次)会有一个短暂的窗口,它引入了一个突破性的变化,我们没有一个支持该版本的更新webdriver gem。
我正在使用wedriveri o 4.5: 我需要等到某个元素存在,如果它不存在,处理这种情况。 例如: 但如果页面上不存在元素,webdriver会将我的测试标记为失败,并显示消息:“超时10000毫秒。”。尝试减少运行时间或增加测试规格的超时时间(http://webdriver.io/guide/testrunner/timeouts.html); 如果回复promise,确保其得到解决 >
下面是一个类和log4j配置: $vi My.java $vi log4j2.xml 在日志/foo.bar.log中出现和消息。这是我所期望的。但是在日志/foo.log中什么都没有出现,我期望那里有消息。在控制台上也什么都没有出现,但是我期望消息。所以它没有像我预期的那样工作。那么我的错误是什么? 还有LogManager的论点。getLogger必须是记录器的名称。但我也看到了论点是类的例子
我想使用查找从一个集合中获取一些数据并将其放入另一个集合中。 在localfield或foreignfield中写什么都不重要,因为它从player_game_stats中获取所有数据并将其插入player集合中的每个文档中。我想检查localfield和foreignField是否相等,但lookup不检查这一点。我对mongodb使用NoSqlBooster
然后更新状态: 由于应该合并,我希望它是: 但相反,它会吃掉id,状态为: 这是预期的行为吗?只更新嵌套状态对象的一个属性的解决方案是什么?
最后是持久性上下文配置: 我很感谢你的帮助。