Forum Discussion

c3r3alkill3r's avatar
c3r3alkill3r
New Contributor
11 years ago

LoadUI, Geb and Selenium

Hi,
I'm trying and failing to get a script to run in Geb Runner. It's very simple, Grab Selenium start Browser.drive and close it. It doesn't do anything else.

@Grab(group='org.codehaus.geb', module='geb-core', version='latest.release')
@Grab(group='org.seleniumhq.selenium', module='selenium-htmlunit-driver', version='latest.release')

import geb.Browser

Browser.drive {

}

When I Run Once on the Geb Runner, the script appears in System Log, it increments the Running figure then stays running for a very long time (approx 10 mins) before Completing with Failed. I've put Selenium stand alone server in the ext directory, but apart from that I can't find any documentation anywhere that explains how to make Selenium WebDriver calls from the Geb Runner.

Please can someone advise what I'm doing wrong?

Additionally, when I open the Script Runner, and add the same script, the Run Once button doesn't enable (I expect because it's not a valid Groovy script). I try and delete it and it doesn't do anything, press close on the dialogue. If I try and delete it again and I get a big java error.

java.lang.RuntimeException: Cannot delete released ModelItem

at com.eviware.loadui.impl.model.ModelItemImpl.delete(ModelItemImpl.java:188)

at com.eviware.loadui.impl.model.ComponentItemImpl.delete(ComponentItemImpl.java:282)

at com.eviware.loadui.ui.fx.api.intent.DeleteTask$DeleteTaskBehavior$1$1.handle(DeleteTask.java:53)

at com.eviware.loadui.ui.fx.api.intent.DeleteTask$DeleteTaskBehavior$1$1.handle(DeleteTask.java:49)

at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)

at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)

at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)

at javafx.event.Event.fireEvent(Event.java:171)

at javafx.scene.Node.fireEvent(Node.java:6863)

at com.eviware.loadui.ui.fx.MenuItemsProvider$3.handle(MenuItemsProvider.java:200)

at com.eviware.loadui.ui.fx.MenuItemsProvider$3.handle(MenuItemsProvider.java:196)

at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:69)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)

at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)

at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:28)

at javafx.event.Event.fireEvent(Event.java:171)

at javafx.scene.Node.fireEvent(Node.java:6863)

at javafx.scene.control.Button.fire(Button.java:179)

at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:193)

at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:336)

at com.sun.javafx.scene.control.skin.SkinBase$4.handle(SkinBase.java:329)

at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:64)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:217)

at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:170)

at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:38)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:37)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:35)

at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:92)

at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:53)

at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:33)

at javafx.event.Event.fireEvent(Event.java:171)

at javafx.scene.Scene$MouseHandler.process(Scene.java:3328)

at javafx.scene.Scene$MouseHandler.process(Scene.java:3168)

at javafx.scene.Scene$MouseHandler.access$1900(Scene.java:3123)

at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1563)

at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2265)

at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:250)

at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:173)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:292)

at com.sun.glass.ui.View.handleMouseEvent(View.java:528)

at com.sun.glass.ui.View.notifyMouse(View.java:922)

at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)

at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)

at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)

at java.lang.Thread.run(Unknown Source)

Thanks

Paul
  • It's probably worth noting that I'm using LoadUI 2.7.0. Selenium appears to be available by default, so have removed the jar from the ext folder. Still the same result. The Web Runner appears to be working with a particular URL, although it's not logging any output, so can't verify. I've an inkling that this is a proxy issue because nothing at all is registering in Fiddler. There doesn't appear to be any way to configure a proxy from within LoadUI.

    I can't see anything out of the ordinary in Process Monitor, I can see the script being loaded and the Geb and Selenium drivers loading, so it IS doing something, but what that something is I don't know.
  • Hi,

    I have been able to run this script in LoadUI using the Geb Runner. I believe this might be a problem with how LoadUI is handling @Grab.

    What I did was:

    - Tried to run the script in LoadUI and, like you, got this exception that @Grab could not download dependencies....

    - Ran the script using the Groovy Console (which is really great to debug). The following is my full test script:


    @Grab(group='org.codehaus.geb', module='geb-core', version='latest.release') // this is not required, LoadUI includes a version of Geb already.
    @Grab(group='org.seleniumhq.selenium', module='selenium-htmlunit-driver', version='latest.release')

    import geb.Browser

    Browser.drive {
    go "http://05ten.se"
    assert $("img").size() == 2
    }


    - Just try again to run the script in LoadUI. It just worked

    Hope this also works for you!

    Renato
  • Thanks Renato,
    After a lot of playing around, I more or less came to the same conclusion as you, although I ran the script at the command line specifying the proxy. I'm not sure whether specifying the proxy actually made any difference as I didn't test it without beforehand.

    >groovy -Dhttp.proxyHost=proxy.host -Dhttp.proxyPort=8080 C:\Docs\geb.script.groovy

    This then pulled all the dependencies down into the grapes folder. I'm still having issues, but more with the specific functionality, so that's one for another thread!

    Thanks for the reply

    CK