没有元素的应用程序启动

时间:2018-11-06 16:12:18

标签: java appium autotest

当我启动没有appium的应用程序时,我收到以下表格: enter image description here

当我将appium用于应用程序启动元素时,这些元素消失了: enter image description here 有人知道为什么会发生吗?

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();

1 个答案:

答案 0 :(得分:1)

使用以下功能并尝试。

  capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
  capabilities.setCapability(MobileCapabilityType.NO_RESET, true);

此外,请不要在每次初始化驱动程序时尝试重新安装该应用程序。