我在AmazonEC2上运行了Selenium Grid
它由在端口7055上运行的集线器和在端口7056上运行的节点组成。
我有以下测试:
var webdriver = require('selenium-webdriver'),
driver = new webdriver.Builder().
usingServer('http://ec2-50-18-75-182.us-west-1.compute.amazonaws.com:7055/wd/hub').
withCapabilities({'browserName': 'firefox'}).
build();
var postTitle = "Post "+(+new Date);
driver.get('http://si-demo.herokuapp.com/posts/new');
driver.findElement(webdriver.By.id('post_name')).sendKeys("Selenium");
driver.findElement(webdriver.By.id('post_title')).sendKeys(postTitle);
driver.findElement(webdriver.By.id('post_content')).sendKeys("This is auto generated by a test");
driver.findElement(webdriver.By.name('commit')).click();
driver.quit();
当我尝试连接到集线器端口时失败。 当我直接连接到节点端口时,测试会运行。
连接到网格集线器时出现的错误是:
timers.js:103
if (!process.listeners('uncaughtException').length) throw e;
^
Error: ETIMEDOUT connect ETIMEDOUT
at ClientRequest.sendRequest (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/http/index.js:127:16)
at ClientRequest.EventEmitter.emit (events.js:96:17)
at Socket.socketErrorListener (http.js:1436:9)
at Socket.EventEmitter.emit (events.js:96:17)
at Socket._destroy.self.errorEmitted (net.js:329:14)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
==== async task ====
WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:130:49)
at Function.webdriver.WebDriver.createSession (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:109:30)
at Builder.build (/Users/jason/Development/cirrus/spanish-inquisition-runner/node_modules/selenium-webdriver/builder.js:70:22)
at Object.<anonymous> (/Users/jason/Development/cirrus/spanish-inquisition-runner/open_canvas.js:5:8)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
我的问题是: Selenium WebdriverJS是否支持连接到集线器?如果是这样,我做错了什么?
注意:
我在EC2上用来启动网格的命令:
Xvfb :0 -screen 0 1024x768x24 2>&1 >/dev/null &
export DISPLAY=:0
java -jar selenium-server-standalone-2.32.0.jar -port 7055 -role hub
xvfb-run java -jar selenium-server-standalone-2.32.0.jar -role node -hub http://localhost:7055/grid/register
答案 0 :(得分:0)
您是否尝试过使用远程webdriver? 我没有使用JS驱动程序,但C#有一个特定的远程网格连接驱动程序。
https://code.google.com/p/selenium/wiki/WebDriverJs#Using_the_Stand-alone_Selenium_Server
查看JS文档,在构造驱动程序时可能需要执行以下操作:
var webdriver = require('selenium-webdriver'),
SeleniumServer = require('selenium-webdriver/remote').SeleniumServer;