我想安装.apk,然后启动应用程序以使用appium服务器执行任务,但它会安装应用程序,而不是启动应用程序。下面是代码和appium日志
代码:
DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability("platformName", "Android");
cap.setCapability("deviceName", device);
cap.setCapability(CapabilityType.VERSION,version);
cap.setCapability("app", "C:\\Users\\ab.chauhan\\AppData\\Local\\Android\\Sdk\\platform-tools\\AceApp.apk");
cap.setCapability("automationName", cfg.getAutomationName()); cap.setCapability ("appPackage", cfg.getAppPackage()); cap.setCapability ("appActivity", cfg.getAppActivity()); cap.setCapability("noReset", true);
driver = new AndroidDriver(new URL(cfg.getApplicationUrl()), cap); System.out.println(driver);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Appium服务器日志:
[ADB] Getting package info for 'io.appium.unlock' [ADB] Running 'C:\Users\ab.chauhan\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 93e6ecca0903 shell dumpsys package io.appium.unlock' [ADB] The installed 'io.appium.unlock' package does not require upgrade ('2.0.0' >= '2.0.0') [UiAutomator2] Forwarding UiAutomator2 Server port 6790 to 8202 [ADB] Forwarding system: 8202 to device: 6790 [ADB] Running 'C:\Users\ab.chauhan\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 93e6ecca0903 forward tcp:8202 tcp:6790' [ADB] Running 'C:\Users\ab.chauhan\AppData\Local\Android\Sdk\platform-tools\adb.exe -P 5037 -s 93e6ecca0903 shell rm -rf /data/local/tmp/strings.json' [AndroidDriver] Extracting strings from apk [AndroidDriver] C:\Users\ab.chauhan\AppData\Local\Android\Sdk\platform-tools\AceApp.apk [AndroidDriver] undefined [AndroidDriver] C:\Users\AB1636~1.CHA\AppData\Local\Temp\"com.ionicframework.aceappclient150562" [ADB] Extracting strings for language: default [ADB] Successfully extracted 27 strings from 'C:\Users\ab.chauhan\AppData\Local\Android\Sdk\platform-tools\AceApp.apk' resources for '(default)' configuration
答案 0 :(得分:0)
尝试这个
AppiumDriver<MobileElement> driver
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability("automationName", "UiAutomator2");
cap.setCapability("platformName", "Android");
cap.setCapability("deviceName", "Pixel");
cap.setCapability("avd", "Pixel");
cap.setCapability("uiautomator2ServerLaunchTimeout", 20000);
cap.setCapability("appPackage", "abc.xyz.qwe"); //Add app Package name
cap.setCapability("appActivity", "qwe.ewq.avc"); //Add app activity name
cap.setCapability("app", System.getProperty("user.dir") + "/AppBuilds/" + "abc.apk");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap );