简体   繁体   English

在appium自动化期间无法在android app之间切换

[英]Failed to switch between android apps during appium automation

I have the below code. 我有下面的代码。

DesiredCapabilities capabilities =DesiredCapabilities.android();
capabilities.setCapability("device","Android");
            capabilities.setCapability("deviceName","hammerhead");
            capabilities.setCapability("platformName","Android");
            capabilities.setCapability("appPackage","com.android.calculator2");
            capabilities.setCapability("appActivity","com.android.calculator2.Calculator");
AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            driver.findElement(By.xpath("//*[@resource-id='com.android.calculator2:id/digit_7']")).click();
            driver.findElement(By.xpath("//*[@resource-id='com.android.calculator2:id/op_add']")).click();
driver.startActivity("com.android.browser","com.android.browser.BrowserActivity");

"java.lang.reflect.InvocationTargetException" error is thrown on executing driver.startActivity line. 执行driver.startActivity行时引发“ java.lang.reflect.InvocationTargetException”错误。 What mistake I'm making here? 我在这里犯什么错误?

Invocation Target Exception:- This exception occurs when an underlying method throws an exception. 调用目标异常:-当基础方法引发异常时,将发生此异常。 So if there is any method that is invoked using Reflection API throws any runtime exception, the Reflection API will wrap that exception in InvocationTargetException 因此,如果有任何使用Reflection API调用的方法抛出任何运行时异常,则反射API会将异常包装在InvocationTargetException

You can figure out the original/actual exception by using getCause() method on the InvocationTargetException . 您可以使用InvocationTargetException上的getCause()方法找出原始/实际exception

I had the same problem too. 我也有同样的问题。 This is due to the problem of StringUtils. 这是由于StringUtils的问题。 I downloaded Apache Commons Lang plugin and problem was solved. 我下载了Apache Commons Lang插件,问题已解决。

The download can be found here: http://commons.apache.org/proper/commons-lang/download_lang.cgi 可在以下位置找到下载内容: http : //commons.apache.org/proper/commons-lang/download_lang.cgi

After downloading, add commons-lang3-3.4.jar to your external libraries in your IDE. 下载后,将commons-lang3-3.4.jar添加到IDE中的外部库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 关于Android上的Appium自动化的问题 - Questions on Appium Automation on Android 在Appium Android自动化中找不到MobileElement - MobileElement was not found in appium android automation App Center 上的 Appium 无法在 iOS 和 Android (Java) 之间切换 - Appium on App Center can't switch between iOS and Android (Java) 测试期间如何在Android设备之间切换 - How to switch between Android devices during the tests 无法在 Appium Android 中切换语言环境 - Unable to switch locale in Appium Android BrowserStack 不支持 swipeGesture - 使用 Appium 进行自动化 - Android - swipeGesture not supported by BrowserStack - Automation using Appium - Android 元素显示android appium自动化java - is element displayed android appium automation java 如何在android Appium Test Automation中制作可选择的appPackage和appActivity BeforeScenario - how to Make selectable appPackage and appActivity BeforeScenario in android Appium Test Automation Android应用程序自动化脚本:通过Appium,Selenium WebDriver,Java:NoSuchElementFoundException - Android application Automation Script: Through Appium, Selenium WebDriver, Java: NoSuchElementFoundException 无法使用Appium + Android Studio 3.0 + Java 8 - Failed to use Appium + Android Studio 3.0 + Java 8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM