脚本未在两个设备上并行运行,尽管在两个设备上都打开了应用程序,但操作仅在一个设备上进行。其他设备变为空闲状态。
所需功能:
@Parameters({ "deviceName_", "udid_", "platformVersion_", "URL_" })
@BeforeMethod
public void beforeMethod(String deviceName_,String udid_,String platformVersion_,String URL_) throws MalformedURLException, InterruptedException {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", deviceName_);
capabilities.setCapability("platformVersion", platformVersion_);
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("browserName", "");
capabilities.setCapability("appPackage", "com.*******"); //Replace with your app's package
capabilities.setCapability("appActivity", "com.******.login.SplashScreen");
capabilities.setCapability("udid", udid_);
driver = new AndroidDriver(new URL("http://"+URL_), capabilities);
}
Testng xml:
<suite name="Suite" parallel="tests" thread-count="2">
<test name="Test1">
<parameter name="deviceName_" value="ZX1D649DLB"/>
<parameter name="udid_" value="192.168.50.232:5151"/>
<parameter name="platformVersion_" value="6.0"/>
<parameter name="URL_" value="127.0.0.1:4723/wd/hub"/>
<classes>
<class name="com.bm.search_592.ParallelDevice"/>
</classes>
</test>
<test name="Test2">
<parameter name="deviceName_" value="BEPN557TU8SOR4CE"/>
<parameter name="udid_" value="192.168.50.201:5252"/>
<parameter name="platformVersion_" value="6.0.1"/>
<parameter name="URL_" value="127.0.0.1:4726/wd/hub"/>
<classes>
<class name="com.bm.search_592.ParallelDevice"/>
</classes>
</test>
</suite>
答案 0 :(得分:0)
我认为udid参数是错误的,为了为每个设备找到正确的udid,请在Terminal或CMD上执行以下命令:
adb设备
序列号是您在输出中所需要的。
我看到您正在使用不同的端口,这是您所需要的,但是同时打开2个appium服务器并与选定的端口和上限并行。