前几天偶然发现了Geb。我正在使用Grails 2.3.11。我实际上如何正确安装Geb?我下载了jar文件并包含了它们,但是当我尝试运行代码时,我在org.openqa.selenium.WebDriverException
如果这很重要,我正在使用IntelliJ IDEA。
Gebtest.groovy
package gebish
import geb.Browser
class Gebtest {
public static void main(String[] args) {
println "Hi!"
Browser.drive {
go "http://gebish.org"
assert title == "Geb - Very Groovy Browser Automation"
}
}
}
错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/WebDriverException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:344)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:65)
at org.codehaus.groovy.runtime.callsite.CallSiteArray$1.run(CallSiteArray.java:62)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallStaticSite(CallSiteArray.java:62)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.createCallSite(CallSiteArray.java:159)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at gebish.Gebtest.main(Gebtest.groovy:6)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriverException
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 11 more
答案 0 :(得分:1)
我还使用Grails 2.3.11并运行了GEB。已经有一段时间了,所以我不确定到底需要什么,但这是BuildConfig.groovy的某些部分,这些部分可能是相关的:
def gebVersion = "0.13.1"
def webdriverVersion = "2.53.1"
dependencies {
compile "org.codehaus.groovy:groovy-backports-compat23:2.4.13"
test "org.gebish:geb-spock:${gebVersion}"
test "org.seleniumhq.selenium:selenium-support:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-chrome-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-firefox-driver:${webdriverVersion}"
test "org.seleniumhq.selenium:selenium-ie-driver:${webdriverVersion}"
test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
}
plugins {
test(":spock:0.7") {
exclude "spock-grails-support"
}
test "org.grails.plugins:geb:${gebVersion}"
}