当我将appium用于应用程序启动元素时,这些元素消失了: 有人知道为什么会发生吗?
Java代码:
String appPackage = "appPName";
String appActivity = "appAName";
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("platformName", "Android");
cap.setCapability("deviceName", "Custom Phone");
cap.setCapability("platformVersion", "6.0");
cap.setCapability("appPackage", appPackage);
cap.setCapability("appActivity", appActivity);
cap.setCapability("autoGrantPermissions", "true");
System.out.println("---------------------------------Create session---------------------------------");
URL device_url = new URL("http://localhost:4723/wd/hub");
try
{
driver = new AndroidDriver(device_url, cap);
}
catch(Exception ex)
{
System.out.println(ex.getMessage());
}
System.out.println("----------------------------------Is the application installed?--------------------------------");
applicationInstalled = driver.isAppInstalled(appPackage);
System.out.println("Application installed status: " + applicationInstalled);
System.out.println("------------------------------------------------------------------");
driver.quit();
答案 0 :(得分:1)
使用以下功能并尝试。
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
此外,请不要在每次初始化驱动程序时尝试重新安装该应用程序。