I tried the equivalent htmlunit version:

////////////////////////////////////
@Grab('org.gebish:geb-core:7.0')
@GrabExclude('org.apache.groovy:groovy-xml')
@GrabExclude('org.apache.groovy:groovy-macro')
@Grab('org.seleniumhq.selenium:selenium-support:4.25.0')
@Grab('org.seleniumhq.selenium:htmlunit-driver:4.13.0')
import geb.Browser
Browser.drive {
    go "http://gebish.org";

    assert title == "Geb - Very Groovy Browser Automation"

    $("div.menu a.manuals").click()
    waitFor { !$("#manuals-menu").hasClass("animating") }

    $("#manuals-menu a")[0].click()

    assert title.startsWith("The Book Of Geb")
}
////////////////////////////////////

I also created a hello world gradle project here:

https://github.com/paulk-asert/groovy-geb-hello

When I run its copyDependenciesToLib task it copies over 60 jars into
the lib directory.

I can then run:

$ groovy -cp build/lib/* src/main/groovy/HelloGeb.groovy

but I suspect many of those jars aren't needed for this simple example.

Regards, Paul.

On Fri, Oct 18, 2024 at 4:16 AM o...@ocs.cz <o...@ocs.cz> wrote:
>
> Hi there,
>
> well, looks like the claim “all I need is geb-core JAR” is patently false :( 
> When instead of downloading the JAR manually and putting it to the classpath 
> (which approach I happen to strongly prefer) I use @Grab to get dependences 
> as well, it more-or-less starts working.
>
> There are some version clashes to be resolved through @GrabExclude, too. Seem 
> to be nowhere documented, sigh. Also, it looks like there's no way (or at 
> least, I've found none myself) to load the Safari driver implicitly; seems it 
> must be loaded manually, as shown below (but as always, I might be missing 
> something of importance here).
>
> Eventually, this way it seems to work, at least with simple test cases (if 
> anybody tries, do not forget to enable the driver using safaridriver 
> --enable; by my experience must be always done as root, an admin does not 
> suffice, and to spread confusion, instead of “no privilege” or so it reports 
> a bad password):
>
> ===
> @Grab('org.gebish:geb-core:7.0')
> @GrabExclude('org.apache.groovy:groovy-xml')
> @GrabExclude('org.apache.groovy:groovy-macro')
> @Grab('org.seleniumhq.selenium:selenium-support:4.25.0')
> @Grab('org.seleniumhq.selenium:selenium-safari-driver:4.25.0')
>
> import geb.Browser
> import org.openqa.selenium.safari.*
>
> Browser.drive(driver:SafariDriver.newInstance(SafariOptions.newInstance())) {
>     ... test case as needed ...
> }.quit()
> ===
>
> All the best,
> OC
>
> On 17. 10. 2024, at 17:59, OCsite <o...@ocs.cz> wrote:
>
> Hi there,
>
> based on the latest debate in the devlist, I'm trying to play with Geb. The 
> Book of Geb quite explicitly says that all I need is geb-core jar, a 
> WebDriver driver implementation and the selenium-support jar, nevertheless, 
> it does not seem so; it looks like the geb-core JAR does not contain 
> GebException:
>
> ===
> 1065 ocs /tmp> <geb.groovy
> import geb.Browser
> Browser.drive {
>     to GebHomePage
>     manualsMenu.open()
>     manualsMenu.links[0].click()
>     at TheBookOfGebPage
> }
> 1066 ocs /tmp> ls -l *.jar
> -rw-r--r--@ 1 ocs  wheel  750068 Oct 17 17:24 geb-core-7.0.jar
> -r-xr-xr-x@ 2 ocs  staff  174337 Jan  1  2010 selenium-support-4.25.0.jar*
> 1067 ocs /tmp> /usr/local/groovy-4.0.21/bin/groovy -cp 
> geb-core-7.0.jar:selenium-support-4.25.0.jar -d geb
> Caught: java.lang.NoClassDefFoundError: geb/error/GebException
> ... ... ...
> 1068 ocs /tmp> unzip -l geb-core-7.0.jar|fgrep GebException
> 1069 ocs /tmp>
> ===
>
> What do I do wrong? Thanks!
> OC
>
> === full stack in case it helps, which I seriously doubt:
> 1067 ocs /tmp> /usr/local/groovy-4.0.21/bin/groovy -cp 
> geb-core-7.0.jar:selenium-support-4.25.0.jar -d geb
> Caught: java.lang.NoClassDefFoundError: geb/error/GebException
> java.lang.NoClassDefFoundError: geb/error/GebException
> at java.base/java.lang.ClassLoader.defineClass1(Native Method)
> at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
> at 
> java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
> at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:550)
> at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
> at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
> at java.base/java.security.AccessController.doPrivileged(Native Method)
> at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
> at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:143)
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
> at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
> at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3137)
> at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2357)
> at 
> org.codehaus.groovy.reflection.CachedClass$2.lambda$initValue$4(CachedClass.java:68)
> at java.base/java.security.AccessController.doPrivileged(Native Method)
> at 
> org.codehaus.groovy.reflection.CachedClass.doPrivileged(CachedClass.java:160)
> at org.codehaus.groovy.reflection.CachedClass.access$000(CachedClass.java:45)
> at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:73)
> at org.codehaus.groovy.reflection.CachedClass$2.initValue(CachedClass.java:63)
> at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:50)
> at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:37)
> at 
> org.codehaus.groovy.reflection.CachedClass.getConstructors(CachedClass.java:276)
> at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:232)
> at groovy.lang.MetaClassImpl.<init>(MetaClassImpl.java:242)
> at 
> groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createNormalMetaClass(MetaClassRegistry.java:166)
> at 
> groovy.lang.MetaClassRegistry$MetaClassCreationHandle.createWithCustomLookup(MetaClassRegistry.java:156)
> at 
> groovy.lang.MetaClassRegistry$MetaClassCreationHandle.create(MetaClassRegistry.java:139)
> at 
> org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:271)
> at org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:314)
> at 
> org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:269)
> at 
> org.codehaus.groovy.vmplugin.v8.Selector$MethodSelector.getMetaClass(Selector.java:575)
> at 
> org.codehaus.groovy.vmplugin.v8.Selector$MethodSelector.setCallSiteTarget(Selector.java:1020)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fallback(IndyInterface.java:360)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.access$000(IndyInterface.java:50)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface$FallbackSupplier.get(IndyInterface.java:282)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.lambda$fromCache$1(IndyInterface.java:304)
> at 
> org.codehaus.groovy.vmplugin.v8.CacheableCallSite.getAndPut(CacheableCallSite.java:70)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.lambda$fromCache$2(IndyInterface.java:301)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.doWithCallSite(IndyInterface.java:376)
> at 
> org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:298)
> at geb.run(geb.groovy:2)
> at 
> groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:287)
> at groovy.lang.GroovyShell.run(GroovyShell.java:393)
> at groovy.lang.GroovyShell.run(GroovyShell.java:382)
> at groovy.ui.GroovyMain.processOnce(GroovyMain.java:649)
> at groovy.ui.GroovyMain.run(GroovyMain.java:389)
> at groovy.ui.GroovyMain.access$1400(GroovyMain.java:67)
> at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:313)
> at groovy.ui.GroovyMain.processArgs(GroovyMain.java:141)
> at groovy.ui.GroovyMain.main(GroovyMain.java:114)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 
> Method)
> at 
> java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at 
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:115)
> at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:37)
> Caused by: java.lang.ClassNotFoundException: geb.error.GebException
> at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:180)
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
> at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:148)
> at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
> ... 56 more
>
>

Reply via email to