我有以下设置:
我使用以下配置在本地PC上运行网格集线器: java -jar selenium-server-standalone-2.42.0.jar -role hub -grid1Yml grid_configuration.yml
配置如下所示:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "Firefox on Windows"
browser: "*firefox"
...
我通过
启动节点java -jar selenium-server -standalone-2.42.0.jar -role node -hub http://localhost:4444/grid/register -port 8888 -browser "browserName=Firefox on windows,maxInstances=1,version=1,platform=WINDOWS"
我的测试设置如下:
public static void main(String[] args) throws MalformedURLException {
System.setProperty("webdriver.ie.driver","C:\\IEDriverServer.exe");
DesiredCapabilities cap = DesiredCapabilities.firefox();
cap.setBrowserName("*firefox");
RemoteWebDriver remoteWebDriver = new RemoteWebDriver(new URL("http://127.0.0.1:4444" + "/wd/hub"), cap);
}
如果我运行我的测试,我会收到以下错误:
Exception in thread "main" org.openqa.selenium.WebDriverException: Error forwarding
the new session webdriver new session JSON response body did not contain a session ID
Command duration or timeout: 946 milliseconds
Build info: version: '2.41.0', revision: '3192d8a6c4449dc285928ba024779344f5423c58', time: '2014-03-27 11:29:39'
System info: host: 'CL-CNU416C97F', ip: '10.11.112.158', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_55'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
在webdriver节点中,我收到了重要的错误: 例外:驱动程序可执行文件的路径必须由webdriver.ie.driver系统属性设置...
我已经通过java和我的windows环境设置了这个属性。我不知道为什么我仍然收到此错误消息。
如果我使用grid2配置文件(json),如何在每台主机上按名称设置单个浏览器。
示例:
hub:
port: 4444
remoteControlPollingIntervalInSeconds: 180
sessionMaxIdleTimeInSeconds: 300
newSessionMaxWaitTimeInSeconds: 600
environments:
- name: "MyFireFox on MyMachine1"
browser: "*firefox"
- name: "MyFireFox on MyMachine2"
browser: "*firefox"
如果我使用此集线器配置,我可以通过说它是“MyMireFox on MyMachine1”浏览器来启动节点。属性浏览器告诉webdriver在系统上使用Firefox
如果我现在使用grid2配置json,我有以下
{
"capabilities":
[
{
"browserName": "MyFireFox on MyMachine1",
"platform": "WINDOWS",
"maxInstances": 1
},
但这不起作用,因为我认为browserName是grid1 config中的浏览器。
答案 0 :(得分:0)
这是来自我的.bat文件的配置。另外,为什么要将节点端口更改为8888?尝试删除'-port 8888'并再次检查
for hub:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role hub
表示节点:
java -jar path_to_selenium-server-standalone-2.41.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=firefox, platform=WINDOWS
这是我的json和bat文件100%正常工作
{
"capabilities":
[
{
"browserName": "firefox",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "internet explorer",
"version": "10",
"platform": "WINDOWS",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"port":5555,
"hubPort":4444,
"hubHost":"192.168.3.104",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
和bat从json
启动节点java -jar selenium-server-standalone-2.41.0.jar -role node -nodeConfig nodeConfig_win7.json
同样在系统路径中你应该添加路径到带有浏览器驱动程序的文件夹