gpt4 book ai didi

ruby - webdriver ruby​​ 绑定(bind)中的所需功能

转载 作者:太空宇宙 更新时间:2023-11-03 16:24:26 24 4
gpt4 key购买 nike

我将 selenium 网格与用 ruby​​/watir/cucumber 编写的测试一起使用,以通过并行化加速。我的网格中有一些我想在工作日使用的节点,还有一些我只想在晚上使用的节点。我认为可以通过使用 applicationName 功能来实现。现在我的代码看起来像这样:

@driver= FigNewton.browser
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 360
@env = ENV['ENV']
@env ||= 'local'
if @env == 'local' then
@browser = Watir::Browser.new @driver , :http_client => client
else
@hub_url = ENV['HUB_URL']
@hub_url ||= 'http://localhost:4444/wd/hub'
@browser = Watir::Browser.new(:remote, :url=>"http://localhost:4444/wd/hub", :desired_capabilities => @driver.downcase.to_sym)
end

但是当我以这种方式设置功能时,无法更改 applicationName。所以我尝试使用下一个代码:

@driver= FigNewton.browser
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 360
@env = ENV['ENV']
@env ||= 'local'
if @env == 'local' then
@browser = Watir::Browser.new @driver , :http_client => client
else
@hub_url = ENV['HUB_URL']
@hub_url ||= 'http://localhost:4444/wd/hub'
caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps[:applicationName] = "test"
@browser = Watir::Browser.new(:remote, :url=>"http://localhost:4444/wd/hub", :desired_capabilities => caps)
end

我的节点使用下一个命令启动:

 java -jar selenium-server-standalone-2.44.0.jar -role node -host testHost  -hub http://localhost:4444/grid/register -maxSession 20 -browser browserName=firefox,maxInstances=10 -browser browserName=chrome,maxInstances=10,applicationName=test

但是当我使用第二种方法时,我遇到了下一个异常:

Error forwarding the new session cannot find : Capabilities [{platform=ANY, cssSelectorsEnabled=true, javascriptEnabled=true, browserName=firefox, applicationName=test, nativeEvents=false, rotatable=false, takesScreenshot=true, version=}] (org.openqa.grid.common.exception.GridException) (Selenium::WebDriver::Error::UnknownError)

无法弄清楚哪里出了问题。

有没有其他方法可以过滤网格中的节点?

最佳答案

找到 Undocumented way to select a node on a Selenium Grid2 , 希望对你有帮助

NODE1:

java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://HUB_IP:4444/grid/register -browser browserName=firefox,version=11,maxInstances=1,platform=WINDOWS,applicationName=windows7_32bits_firefox_11

NODE2:

java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://HUB_IP:4444/grid/register -browser browserName=firefox,version=11,maxInstances=1,platform=WINDOWS,applicationName=windows7_64bits_firefox_11

In your tests you have to add "applicationName=windows7_32bits_firefox_11" to your desired capabilities array.

关于ruby - webdriver ruby​​ 绑定(bind)中的所需功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27599217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com