问题描述
我在黄瓜中设置了一个功能,并使用@javascript标签让它运行在selenium
在我的dev机器selenium运行良好,但因为webdriver不支持本地事件在osx,但我需要将其挂接到运行ubuntu的虚拟机
I've set up a feature in cucumber and am using the @javascript tag to have it run in seleniumOn my dev machine selenium runs fine but because webdriver doesn't support native events on osx yet I need to hook it up to a virtual machine running ubuntu
我的ubuntu机器上运行webdriver服务器
I've got webdriver server running on my ubuntu machine
并且黑客我的水豚驱动程序像这样连接到远程服务器像这样:
and hacked my capybara driver like so it connect to the remote server like so:
def browser
unless @browser
@browser = Selenium::WebDriver.for(:remote, :url => "http://192.168.1.69:4444/wd/hub",
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox)
#@browser = Selenium::WebDriver.for(options.delete(:browser) || :firefox, options)
at_exit do
@browser.quit
end
end
@browser
end
当我运行我的测试控制台在我的虚拟机上显示了一些进展和输出:
When I running my test the console on my virtual machine shows somethings going on and outputs:
WebDriver远程服务器:INFO执行....
WebDriver remote server: INFO executing ....
但是由于超时一段时间后测试失败
But thats it the test fails after some time due to timeout
任何想法?
推荐答案
我不知道是什么导致你的具体问题。但您应该使用内置的机制注册您的驱动程序:
I am not sure what is causing your specific problem. But you should register your driver using the built in mechanism:
profile = Selenium::WebDriver::Firefox::Profile.new
profile["network.http.use-cache"] = false
Capybara.register_driver :firefox_ubuntu do |app|
Capybara::Driver::Selenium.new(app,
:browser => :remote,
:url => 'http://192.168.1.69:4444/wd/hub',
:desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
)
end
,然后您可以使用常规机制切换到它:
and then you can switch to it using the normal mechanism:
Capybara.current_dirver :firefox_ubuntu
这篇关于远程Selenium WebDriver没有响应Cucumber测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!