您好:我正在使用java在网格上运行带有appium 1.6.5的selenium 3.5.3。
目标:
在任何可用的浏览器版本和任何可用的操作系统(即windows,mac,linux,android,ios)上并行运行测试。对于这个例子,我使用了android和windows。
预期:
当我运行TestRunner脚本(下面提供)时,我希望所有5个测试按此处并行运行:
结果
请帮忙。
如何使这项工作能够在所有浏览器上并行运行测试。具体来说,如何为firefox解决它以及如何为android-chrome解决它。
TestRunner脚本
public class SeleniumGrid {
@DataProvider (name = "DP", parallel=true)
Object[][] DataGen(){
String [][] arr = new String[][]{{"1"}, {"2"}, {"3"},{"4"}, {"5"}};
return arr;
}
@Test (dataProvider = "DP")
void TestProvider(String value) throws MalformedURLException{
System.out.println(value);
DesiredCapabilities cap = new DesiredCapabilities();
//cap.setCapability(CapabilityType.BROWSER_NAME, "firefox");
cap.setCapability(CapabilityType.PLATFORM, org.openqa.selenium.Platform.ANY);
//cap.setCapability(CapabilityType.VERSION, "8");
//**** AndroidDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://localhost:4444/wd/hub/"), cap);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), cap);
driver.get("http://www.testng.org");
driver.quit();
}
}
NODE1_windows config:
{
"capabilities": [
{
"browserName": "firefox",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "chrome",
"platform": "WINDOWS",
"maxInstances": 1,
"version": "9"
}
],
"maxSession": 2,
"port": 5555,
"register": true
}
NODE2_windows config:
{
"capabilities": [
{
"browserName": "firefox",
"platform": "WINDOWS",
"maxInstances": 1
},
{
"browserName": "chrome",
"platform": "WINDOWS",
"maxInstances": 1,
"version": "9"
}
],
"maxSession": 2,
"port": 5556,
"register": true
}
NODE3_android config:
{
"capabilities": [
{
"platform" : "ANDROID",
"browserName": "Chrome",
"version": "5.1.1",
"device" : "Appium",
"applicationName": "myNexus5",
"maxInstances": 1
}
],
"configuration": {
"cleanUpCycle": 2000,
"timeout": 30000,
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"host": "127.0.0.1",
"port": 4723,
"maxSession": 1,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": "192.168.1.100",
"role" : "node"
}
}
HUB&amp;的CLI启动器NODES
- java -jar selenium-server-standalone-3.5.3.jar -role hub
- java -Dwebdriver.chrome.driver="E:\drivers\chromedriver.exe" -jar selenium-server-standalone-3.5.3.jar -role node -hub http://localhost:4444/grid/register -nodeConfig node1_windows.json
- java -Dwebdriver.chrome.driver="E:\drivers\chromedriver.exe" -jar selenium-server-standalone-3.5.3.jar -role node -hub http://localhost:4444/grid/register -nodeConfig node2_windows.json
- appium --nodeconfig node3_android.json -p 4723 -bp 4724 -U 06f0111111c86e3e