我正在尝试使用 appium 和 selenium 网格在 2 台设备上运行并行测试,但由于某种原因,它仅在第一个节点服务器(和第一个设备)上运行,但在第二个服务器上没有任何反应。
此外,如果我关闭第一台服务器并运行测试,那么测试将在第二台服务器上运行,因此服务器不应该有任何问题。
为了将其设置为并行,我必须提供一些参数吗?
谢谢您的帮助 !
这是我的文件:
第一个服务器 json 文件:
{
"capabilities":
[
{
"browserName": "SamsungS6",
"deviceName": "04157df40862d02f",
"version":"6.0.1",
"maxInstances": 3,
"platform":"ANDROID"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://localhost:4491/wd/hub",
"host": "localhost",
"port": 4491,
"maxSession": 5,
"register": true,
"registerCycle": 5000,
"hubPort": 4433,
"hubHost": "localhost"
}
}
第二个服务器 json 文件:
{
"capabilities":
[
{
"browserName": "OnePlusOne",
"deviceName": "14b2b276",
"version":"6.0.1",
"maxInstances": 3,
"platform":"ANDROID",
"platformName":"ANDROID"
}
],
"configuration":
{
"cleanUpCycle":2000,
"timeout":30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"url":"http://localhost:4490/wd/hub",
"host": "localhost",
"port": 4490,
"maxSession": 5,
"register": true,
"registerCycle": 5000,
"hubPort": 4433,
"hubHost": "localhost"
}
}
运行硒网格:
java -jar selenium-server.jar -role hub -port 4433
运行第一个场景
node.exe node_modules\appium\bin\appium.js --nodeconfig myfirstscenario.json -p 4490 -U 14b2b276 -bp 5490 --chromedriver-port 6490
运行第二个场景
node.exe node_modules\appium\bin\appium.js --nodeconfig mysecondscenario.json -p 4491 -U 04157df40862d02f -bp 5491 --chromedriver-port 6491
考试
@BeforeTest(alwaysRun = true)
public void setUp(){
try {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "ANDROID");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "");
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, appPackage);
capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, appActivity);
driver = new AndroidDriver(new URL("http://localhost:4433/wd/hub"), capabilities);
new WebDriverWait(driver, 60);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
@Test
public void test(){
System.out.println("hello world");
try {
sleep(6000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
@AfterTest(alwaysRun = true)
public void closeDriver(){
driver.quit();
}