我只是尝试在移动应用上进行自动化测试,但面临以下问题:
仅使用以下代码安装ES-File-Explorer-Pro-1.1.2-Mod.apk
个应用程序,但其他应用程序失败
public static void main(String[] args) throws Exception{
File appDir=new File("Drivers");
File app=new File(appDir, "ES-File-Explorer-Pro-1.1.2-Mod.apk");
DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME,"Android Emulator");
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());
WebDriver driver=new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), cap);
使用其他应用,看到以下错误
Exception in thread "main" org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Remote install failed: pkg: /data/local/tmp/6811571d7ee802f0b73db5e59deef57a.apk
Failure [INSTALL_FAILED_NO_MATCHING_ABIS] (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 39.19 seconds
另外,如果我的代码中有新的错误,请告诉我任何愚蠢的错误。
由于
答案 0 :(得分:0)
public AndroidDriver<AndroidElement> setUp() throws MalformedURLException{
DesiredCapabilities capabilities = DesiredCapabilities.android();
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Test");
capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT,60);
capabilities.setCapability("appPackage", "com.android.vending");
capabilities.setCapability("appActivity", "com.google.android.finsky.activities.MainActivity");
driver = new AndroidDriver<AndroidElement>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
return driver;
}
@Test
public void Test() {
driver.findElement(By.id("ctl00_ContentPlaceHolder1_btnSubmit")).click();
}
尝试返回驱动程序。