Вызов элементов пользовательского интерфейса с помощью Appium в тестах Cucumber в Java Android приводит к сбою сборки с большим количеством журналов. - PullRequest
0 голосов
/ 15 мая 2019

Я настроил тесты на огурец.Работает нормально для моей деятельности.
Я также настроил тесты пользовательского интерфейса Appium, которые также прекрасно работают при вызове.
Теперь я хочу вызвать элементы пользовательского интерфейса своей деятельности с помощью Appium в тестах Cucumber, которые записаны в файле stepdefinitions.

Мой 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')

В папке шагов Cucumber.Я написал тесты, которые работают нормально.Проверено в журналах.
Теперь, когда я добавляю код appium в функцию установки шагов, чтобы вызвать LoginActivity, я могу получить доступ к таким элементам пользовательского интерфейса, как это:

@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

1 Ответ

1 голос
/ 15 мая 2019

Похоже, вы пытаетесь создать тест на основе Appium с Android SDK , и компиляция завершается неудачно, поскольку Appium использует Java SDK

Итак, архитектура вашего теста должна выглядеть так:

  1. Приложение, скомпилированное с помощью Android SDK, развернутого на устройстве Android (или эмуляторе)
  2. Ваши тесты, скомпилированные с Java SDK, развернутым на вашем компьютере
  3. Android-устройство (или эмулятор), подключенное к компьютеру через ADB

Таким образом, ваши тесты будут контролировать устройство Android и выполнять клики, пролистывания, ввод текста, утверждения и т. Д. Поэтому вам необходимо пересмотреть подход к созданию тестового проекта.

Если вы хотите, чтобы тесты пользовательского интерфейса были неотъемлемой частью вашей сборки приложения для Android, рассмотрите возможность перехода на Espresso , ознакомьтесь с Как начать работу с Espresso (Android) , чтобы узнать больше о концепция / реализация.

...