答案 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()函数