我已经配置了黄瓜测试。我的活动正常。
我还配置了Appium UI测试,该测试在调用时也可以正常工作。
现在,我想在用stepdefinitions文件编写的Cucumber测试下用Appium调用活动的UI元素。
我的build.gradle
// Cucumber for E2E testing
androidTestImplementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'info.cukes:cucumber-android:1.2.5'
androidTestImplementation 'info.cukes:cucumber-picocontainer:1.2.5'
// Appium for DI -- implementation / compileOnly
implementation 'io.appium:java-client:6.1.0'
implementation files('libs/java-client-6.1.0.jar')
implementation files('libs/selenium-server-standalone-3.13.0.jar')
在“黄瓜步骤”文件夹中。我写的测试工作正常。通过日志检查。
现在,当我在步骤设置函数中添加appium代码以调用LoginActivity时,我可以访问如下UI元素:
@Before("@login-scenarios")
public void setUp() throws java.net.MalformedURLException {
System.out.println(Tag + "start - setUp in LoginStepdefs");
org.openqa.selenium.remote.DesiredCapabilities capabilities = new org.openqa.selenium.remote.DesiredCapabilities();
capabilities.setCapability("deviceName", "Emulator Nexus_4_API_22 Android 5.1.1, API 22");
capabilities.setCapability(org.openqa.selenium.remote.CapabilityType.PLATFORM, "Android");
capabilities.setCapability(org.openqa.selenium.remote.CapabilityType.VERSION, "5.1.1");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("appPackage", "com.my.app");
capabilities.setCapability("appActivity", ".activities.MainActivity");
capabilities.setCapability("unicodeKeyboard", true);
capabilities.setCapability("resetKeyboard", true);
driver = new io.appium.java_client.AppiumDriver(new java.net.URL("http://127.0.0.1:1234/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5, java.util.concurrent.TimeUnit.SECONDS);
}
@After("@login-scenarios")
public void tearDown() {
System.out.println(Tag + "stop - tearDown in LoginStepdefs");
driver.quit();
}
@Given("^Login screen is launched$")
public void loginScreenIsLaunched() {
System.out.println(Tag + "1 - loginScreenIsLaunched");
org.openqa.selenium.support.ui.WebDriverWait wait = new org.openqa.selenium.support.ui.WebDriverWait(driver, 10);
wait.until(org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated(org.openqa.selenium.By.id(com.my.app.utilities.Constant.APP_PACKAGE + signinEmailId)));
}
现在,当我运行黄瓜测试时。控制台中有大量日志,一段时间后构建失败。
我正在发布日志。我哪里错了?
AGPBI: {"kind":"warning","text":"Type `javax.imageio.ImageIO` was not found, it is required for default or static interface methods desugaring of `void io.appium.java_client.ios.HasIOSClipboard.setClipboardImage(java.awt.image.BufferedImage)`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/java-client-6.1.0.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `javax.xml.bind.DatatypeConverter` was not found, it is required for default or static interface methods desugaring of `byte[] io.appium.java_client.InteractsWithFiles.pullFile(java.lang.String)`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/java-client-6.1.0.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `javax.imageio.ImageIO` was not found, it is required for default or static interface methods desugaring of `void io.appium.java_client.ios.HasIOSClipboard.setClipboardImage(java.awt.image.BufferedImage)`","sources":[{"file":"/home/sajid/.gradle/caches/modules-2/files-2.1/io.appium/java-client/6.1.0/6bb22d04886b87f525e4ea352b1940a6ff8c471b/java-client-6.1.0.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `javax.xml.bind.DatatypeConverter` was not found, it is required for default or static interface methods desugaring of `byte[] io.appium.java_client.InteractsWithFiles.pullFile(java.lang.String)`","sources":[{"file":"/home/sajid/.gradle/caches/modules-2/files-2.1/io.appium/java-client/6.1.0/6bb22d04886b87f525e4ea352b1940a6ff8c471b/java-client-6.1.0.jar"}],"tool":"D8"}
JarCode: JSR encountered; reparse using JSRInlinerAdapter
AGPBI: {"kind":"warning","text":"Type `javax.imageio.ImageIO` was not found, it is required for default or static interface methods desugaring of `void org.eclipse.jetty.util.preventers.AppContextLeakPreventer.prevent(java.lang.ClassLoader)`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `org.apache.log.Hierarchy` was not found, it is required for default or static interface methods desugaring of `org.apache.log.Logger org.apache.commons.logging.impl.LogKitLogger.getLogger()`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
JarCode: JSR encountered; reparse using JSRInlinerAdapter
JarCode: JSR encountered; reparse using JSRInlinerAdapter
JarCode: JSR encountered; reparse using JSRInlinerAdapter
Expiring Daemon because JVM Tenured space is exhausted
Daemon will be stopped at the end of the build after running out of JVM memory
AGPBI: {"kind":"warning","text":"Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.\u003cclinit\u003e()`","sources":[{"file":"/home/sajid/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.cache.Striped64.getUnsafe()`","sources":[{"file":"/home/sajid/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `javax.imageio.ImageIO` was not found, it is required for default or static interface methods desugaring of `void org.seleniumhq.jetty9.util.preventers.AppContextLeakPreventer.prevent(java.lang.ClassLoader)`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
JarCode: JSR encountered; reparse using JSRInlinerAdapter
AGPBI: {"kind":"warning","text":"Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `sun.misc.Unsafe com.google.common.hash.LittleEndianByteArray$UnsafeByteArray.getUnsafe()`","sources":[{"file":"/home/sajid/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/27.0.1-android/b7e1c37f66ef193796ccd7ea6e80c2b05426182d/guava-27.0.1-android.jar"}],"tool":"D8"}
> Task :app:transformClassesWithDexBuilderForDebug
Expiring Daemon because JVM Tenured space is exhausted
AGPBI: {"kind":"warning","text":"Type `javax.swing.JTree` was not found, it is required for default or static interface methods desugaring of `void net.sourceforge.htmlunit.corejs.javascript.tools.debugger.treetable.JTreeTable$TreeTableCellRenderer.updateUI()`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
AGPBI: {"kind":"warning","text":"Type `javax.swing.UIManager` was not found, it is required for default or static interface methods desugaring of `void net.sourceforge.htmlunit.corejs.javascript.tools.debugger.treetable.JTreeTable$TreeTableCellRenderer.updateUI()`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
JarCode: JSR encountered; reparse using JSRInlinerAdapter
AGPBI: {"kind":"warning","text":"Type `sun.misc.Unsafe` was not found, it is required for default or static interface methods desugaring of `void com.google.common.util.concurrent.AbstractFuture$UnsafeAtomicHelper.\u003cclinit\u003e()`","sources":[{"file":"/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar"}],"tool":"D8"}
> Task :app:transformClassesWithDexBuilderForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process /home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 5m 58s
21 actionable tasks: 6 executed, 15 up-to-date
Expiring Daemon because JVM Tenured space is exhausted
答案 0 :(得分:1)
您似乎正在尝试使用Appium构建基于Android SDK的测试,并且由于Appium依赖于Java SDK而导致编译失败
因此,您的测试架构应如下所示:
这样,您的测试将控制Android设备并执行单击,滑动,键入,声明等操作。因此,您需要重新考虑构建测试项目的方法。
如果您希望UI测试成为Android应用程序构建的组成部分,请考虑切换到Espresso,请查看How to Get Started with Espresso (Android),以了解有关概念/实现的更多信息。