Kotlin 通过 Gradle 构建脚本没有执行 WebDriver spek



存储库,紧密再现了我的问题:https://github.com/paul-hammant/kotlin-webdriver-snafu

规格,再简单不过了:

class WebDriverSpeks : Spek({
ChromeDriverManager.getInstance().setup()
val co = ChromeOptions()
val chromeDriver = ChromeDriver(co) as WebDriver
beforeGroup {
chromeDriver.get("https://yahoo.com/")    
}
describe("yahoo") {
it("should have index.html") {
assertEquals(chromeDriver.title, "hello")
}    
}
afterGroup {
chromeDriver.close()
}
})

Intellij 中没有红线表示编译失败,但是当gradle build运行时,它会抱怨传递 dep:

$ gradle build
Download https://jcenter.bintray.com/org/slf4j/slf4j-api/1.7.24/slf4j-    api-1.7.24.jar
w: Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/paul/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.2.30/f916048adc012c9342b796a5f84c0ac6205abcac/kotlin-stdlib-jdk8-1.2.30.jar (version 1.2)
/Users/paul/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.30/ca12c47fc1e3a7316067b2a51e2f214745ebf8c5/kotlin-stdlib-jdk7-1.2.30.jar (version 1.2)
/Users/paul/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/1.0.6/3d499d3b7768f88c4796e5a1e357933e11a8936d/kotlin-reflect-1.0.6.jar (version 1.0)
/Users/paul/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.2.30/2dfac33f8b4e92c9dd1422cd286834701a6f6d6/kotlin-stdlib-1.2.30.jar (version 1.2)
w: Consider providing an explicit dependency on kotlin-reflect 1.2 to prevent strange errors
w: Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath or use '-Xskip-runtime-version-check' to suppress this warning
e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class org.openqa.selenium.chrome.ChromeDriver, unresolved supertypes:    org.openqa.selenium.remote.RemoteWebDriver

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileTestKotlin'.
> Compilation error. See log for more details
* 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
BUILD FAILED in 6s
5 actionable tasks: 5 executed

据称未解析的超类型 org.openqa.selenium.remote.RemoteWebDriver 位于 selenium-remote-driver 中,并且

如果我删除~/.gradle或./build并重试,则是一样的。

如果我检查pom.xml的selenium-java,我可以看到对selenium-remote-driver(存在)的依赖。看这里 - http://central.maven.org/maven2/org/seleniumhq/selenium/selenium-java/3.11.0/selenium-java-3.11.0.pom。jcenter中的那个是一样的。

我不知道为什么Gradle没有找到硒远程驱动程序。我在 Gradle 脚本中注释掉了一个额外的 testCompile,但如果它被注释掉,则没有任何修复。

我认为这是Gradle中的一个问题,或者是Maven Central的一些Gradleized处理,我不太了解,但在某个地方在线。 我不认为这是 Kotlin 的问题。我从一开始就使用Selenium并且非常熟悉它(我已经制作了100个使用Selenium的Maven项目),所以我不认为是这样。当然,我可能错了根本原因在哪里。

嗯,这起到了作用:

rm -rf ~/.m2/repository/org/seleniumhq/

我不知道 Gradle 使用了本地 Maven 存储库缓存。它一定以某种方式腐败了。

希望这对某人有所帮助。

相关内容

最新更新