Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用cucumber远程测试连接到VM时出现问题_Ruby On Rails_Cucumber_Remote Server_Selenium Webdriver - Fatal编程技术网

Ruby on rails 使用cucumber远程测试连接到VM时出现问题

Ruby on rails 使用cucumber远程测试连接到VM时出现问题,ruby-on-rails,cucumber,remote-server,selenium-webdriver,Ruby On Rails,Cucumber,Remote Server,Selenium Webdriver,我有一个cucumber测试套件,我想在InternetExplorer环境中运行。问题是我在linux机器上。所以我三次遵循这个,有点过时 我正在使用本地VM尝试在其上运行测试,并且在那里启动了独立的selenium服务器,它告诉我: RemoteWebDriver实例应连接到:http://127.0.0.1:4444/wb/hub 现在这似乎有点奇怪,我这里有localhost作为连接,但不管它在同一台物理机器上,所以应该不会造成任何问题或问题 接下来,在我的env.rb中,我定义了以下内

我有一个cucumber测试套件,我想在InternetExplorer环境中运行。问题是我在linux机器上。所以我三次遵循这个,有点过时

我正在使用本地VM尝试在其上运行测试,并且在那里启动了独立的selenium服务器,它告诉我:

RemoteWebDriver实例应连接到:http://127.0.0.1:4444/wb/hub

现在这似乎有点奇怪,我这里有localhost作为连接,但不管它在同一台物理机器上,所以应该不会造成任何问题或问题

接下来,在我的
env.rb
中,我定义了以下内容:

Capybara.app_host = "http://hostname:4444"
Capybara.default_driver = :selenium
Capybara.register_driver :selenium do |app|
  Capybara::Selenium::Driver.new(app,
    :browser => :remote,
    :url => "http://MYNETWORKIP:4444/wd/hub",
    :desired_capabilities => :internet_explorer)
end
正如指南所建议的那样。但是当我运行测试时,我得到以下错误:

bad URI(is not URI?): 127.0.0.1:4444/wd/hub (URI::InvalidURIError)
我怀疑这与我在代理背后有关,因为我需要为Firefox(iceweasel)运行做一些特殊设置。 这些设置是:

Capybara.register_driver :selenium do |app|
  profile                                       =   Selenium::WebDriver::Firefox::Profile.new
  profile["network.proxy.type"]                 =   2
  profile["network.proxy.autoconfig_url"]       =   "http config adress here"
  profile["network.proxy.no_proxies_on"]        =   "localhost, 127.0.0.1, #{%x[hostname].gsub("\n", "")}"
  profile["network.proxy.http"]                 =   "proxy http address here"
  profile["network.proxy.http_port"]            =   3128
  profile["network.proxy.ssl"]                  =   "ssl proxy http address here"
  profile["network.proxy.ssl_port"]             =   3128
  profile["network.proxy.share_proxy_settings"] =   true
  Capybara::Selenium::Driver.new(app, :profile => profile)
end
我花了很多时间试图让它现在工作,所以我需要一些帮助 提前Thx

编辑:

意识到某些版本可能会有所帮助。 从gemfile:

 cucumber (1.1.9)
 rails (2.3.11)
 selenium-webdriver (2.20.0)
编辑2:

如果进一步尝试将url更改为我的网络ip地址,则会出现另一个错误:

both URI are relative (URI::BadURIError)
编辑3:

现在在Jon M的帮助下,我走得更远了,但遇到了:

 unexpected response, code=404, content-type="text/html"
编辑4:

最新更新:

更改了my
env.rb中的连接设置

这让我连接到我的virtualbox并启动我的IE浏览器耶!
但是它无法连接到应用程序。

我认为“错误URI”消息是由于缺少协议造成的-请尝试在“127.0.0.1:4444/wd/hub”前面加上“http://”

编辑(响应您的更新):

刚刚发现了地址。。。127.0.0.1引用了
localhost
,但是如果Selenium服务器运行在不同的机器上,您肯定应该使用该机器的IP地址吗


e、 g.

这似乎是问题的一部分,是的。但仍然不能正常工作。如果我使用我的网络Ip地址,我得到一个连接超时,我觉得404至少有点接近。它也在同一台物理机器上,但我使用的是一个VirtualBox,其中我运行的是windows 7和selenium单机服务器您是否在windows VirtualBox来宾上运行cucumber?或者它是在linux/mac主机上运行的?我不完全理解你的问题,但我在普通的linux操作系统上运行测试,我希望它能连接到我的windows Vitrual Box上的selenium服务器。我现在就可以工作了。你是对的,尽管它都在同一台物理机器上,但我仍然需要使用我的网络ip。另外,我忘记了我已经硬编码了我的服务器端口,并且没有在我的应用程序中使用相同的端口,只是在我的回答中添加了一些内容,但是你能澄清selenium服务器在哪里运行吗?你说它在本地虚拟机上,但其他地方说它“在同一台机器上”。如果它实际上是一个VM,那么您必须从主机建立到VM客户机的连接,这可能需要设置一个仅限主机的网络。