我有一个基本的测试,我试图使用Ruby和TestUnit运行。
require "test/unit"
require "rubygems"
gem "selenium-client"
require "selenium/client"
class Test3 < Test::Unit::TestCase
def setup
@verification_errors = []
puts "Running tests..."
@selenium = Selenium::Client::Driver.new \
:host => "http://ec2-54-244-205-27.us-west-2.compute.amazonaws.com:7055/wd/hub",
:browser => "*chrome",
:url => "https://news.google.com/",
:timeout_in_second => 60
@selenium.start_new_browser_session
end
def teardown
@selenium.close_current_browser_session
assert_equal [], @verification_errors
end
def test_test3
@selenium.open "/nwshp?hl=en&tab=wn&authuser=0"
@selenium.click "css=#gb_5 > span.gbts"
@selenium.wait_for_page_to_load "30000"
@selenium.click "css=div.main-appbar"
@selenium.click "css=span.titletext"
end
end
但是,我一直收到以下错误:
SocketError:getaddrinfo:提供了nodename或servname,或者未知
我使用以下行创建了Selenium Hub。
java -jar selenium-server-standalone-2.6.0.jar -role hub -port 7055
然后我通过执行...
注册了WebDriver节点java -jar selenium-server-standalone-2.6.0.jar -role webdriver -hub http://ec2-54-244-205-27.us-west-2.compute.amazonaws.com:7055/grid/register -port 7056
我的网格控制台说......
WebDriverRemoteProxy
listening on http://10.250.11.113:7056/wd/hub
test session time out after 300 sec.
Supports up to 5 concurrent tests from:
我不明白让我的测试与Selenium Grid连接。我做错了什么?我的WebDriver的URL应该是WebDriverRemoteProxy下面的“监听”吗?
答案 0 :(得分:1)
我感觉您已经创建了一个扮演webdriver
角色的集线器节点。
对于向后兼容性,“wd”和“rc”角色是“节点”角色的有效子集。但是这些角色限制了与其相应API的远程连接类型,而“node”允许RC和WebDriver远程连接。
考虑到您正在运行的RC,请尝试将节点的角色定义为rc
或更好地node
java -jar selenium-server-standalone-2.31.0.jar -role node -port 7056 -hub http://ec2-54-244-205-27.us-west-2.compute.amazonaws.com:7055
和您的selenium远程实例一样
@selenium = Selenium::Client::Driver.new \
:host => "http://ec2-54-244-205-27.us-west-2.compute.amazonaws.com:7055/wd/hub",
:browser => "*googlechrome",
:url => "https://news.google.com/",
:timeout_in_second => 60