回复我的问题: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并再次尝试它是相同的 .
如果我检查selenium-java的pom.xml,我可以看到对selenium-remote-driver(存在)的依赖 . 见这里 - http://central.maven.org/maven2/org/seleniumhq/selenium/selenium-java/3.11.0/selenium-java-3.11.0.pom . jcenter中的那个是相同的 .
我不知道为什么Gradle没有找到selenium-remote-driver . 我在Gradle脚本中注释了一个额外的testCompile,但是如果它被注释,则没有任何修复 .
我认为这是Gradle中的一个问题,或者我对Maven Central的一些Gradleized处理我不太了解但在某个地方是在线的 . 我不认为这是一个Kotlin问题 . 我已经使用过Selenium,因为它开始并且我非常熟悉它(我已经制作了100个使用Selenium的Maven项目)所以我不认为就是这样 . 当然,我可能错误的根本原因在哪里 .
1 回答
好吧,这就是诀窍:
我不知道Gradle使用了本地Maven repo缓存 . 它一定是以某种方式腐败了 .
希望这可以帮助别人另一天 .