防止appium桌面客户端强制停止应用程序

时间:2019-08-22 10:52:07

标签: appium

Appium桌面客户端服务器强制停止应用程序

检查添加的屏幕截图中带下划线的代码

enter image description here

1 个答案:

答案 0 :(得分:-1)

您可以通过提供相关的Desired Capability

来通过Appium客户端代码进行控制

您要查找的名称为autoLaunch and defaults to true,只需将其设置为false,Appium就不会停止/重新启动该应用程序。

示例代码:

//Set the Desired Capabilities
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("deviceName", "emulator-5554");
caps.setCapability("udid", "emulator-5554"); //Give Device ID of your mobile phone
caps.setCapability("appPackage", "your.app.package");
caps.setCapability("appActivity", "your.app.package.YourAppActivity");
caps.setCapability("noReset", "true");
caps.setCapability("automationName", "uiautomator2");
caps.setCapability("autoLaunch","false"); // this one will tell Appium not to stop/start the application

AppiumDriver<MobileElement> driver = new AndroidDriver<MobileElement>(new URL("http://0.0.0.0:4723/wd/hub"), caps);

只需确保您的应用正在运行或在需要时手动调用driver.launchApp()函数