build.gradle 中的 Selenium 在将代码迁移到 AndroidX 后失败

Selenium in build.gradle failed after Migrating code to AndroidX

当我将我的项目库升级到 AndroidX 时。迁移到 AndroidX 已完成。

build.gradle 中的这一行:

compileOnly files('libs/selenium-server-standalone-3.13.0.jar')

我收到此构建错误

What went wrong: Execution failed for task ':app:javaPreCompileDebug'.

Could not resolve all files for configuration ':app:debugCompileClasspath'. Failed to transform file 'selenium-server-standalone-3.13.0.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform Failed to transform '/home/sajid/Git/project-android/app/libs/selenium-server-standalone-3.13.0.jar' using Jetifier. Reason: duplicate entry: META-INF/DEPENDENCIES. (Run with --stacktrace for more details.)

我应该怎么做才能使 selenium 工作。

有关更多信息,我正在使用 selenium 进行 appium UI 测试。我将 Appium 添加为:

    compileOnly 'io.appium:java-client:6.1.0'
compileOnly files('libs/java-client-6.1.0.jar')

请大家看看我哪里错了?

我在这里没有得到任何帮助:(

所以经过大量的努力和测试不同的版本。我成功了,Appium/Seleniu 测试现在正在运行。

解决这个问题。我删除了 appium:java-client 和 selenium-server-standalone 的 jar 文件。

然后代替 Selenium Standalon 服务器。我现在使用 selenium-android-driver 最新版本。

这仍然不可行。我在 WebDriver.Wait 上遇到错误。我通过将番石榴版本贬值 28 到 21 来解决这个问题:

api 'com.google.guava:guava:21.0'

然后添加 git appium-java 和 selenium-android 的 repo 地址以将它们添加到项目中:

testImplementation 'io.appium:java-client:7.1.0'
testImplementation 'org.seleniumhq.selenium:selenium-android-driver:2.39.0'

然后在UI下测试类。我将 AppiumDriver 和 WebDriver 更改为 AndroidDriver 为:

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

现在可以使用了