Forum Discussion

gmparker2000's avatar
gmparker2000
New Contributor
11 years ago

PhantomJS with Geb runner

Are there any how tos that explain how to get PhantomJS working in LoadUI with Geb? I can run it fine outside of LoadUI but no luck inside. I tried adding the phantomjsdriver-1.1.0.jar into the ext folder with no luck. I also tried one by one putting these jars into the lib folder (which I assume is not the correct place):

phantomjsdriver-1.1.0.jar
selenium-api-2.41.0.jar
selenium-remote-driver-2.41.0.jar
groovy-1.8.5.jar

Eventually I did not get any more ClassNotFoundExceptions, but now I get problems with groovy not working properly. I assume that it now conflicts with another groovy dependency elsewhere. I get an error about an invalid signature on ConfigSlurper's parse method. Any help would be great. My script looks like this:

@Grab(group='org.codehaus.geb', module='geb-core', version='latest.release')
@Grab(group='com.github.detro.ghostdriver', module='phantomjsdriver', version='1.1.0')

import geb.Configuration
import geb.Browser

def gebConfig = '''
import org.openqa.selenium.*
import org.openqa.selenium.Dimension
import org.openqa.selenium.phantomjs.PhantomJSDriver

reportsDir = "page-reports"

driver = {
def driver = new PhantomJSDriver()
driver.manage().window().setSize(new Dimension(1028, 768))
driver
}
'''

rawGebConfig = new ConfigSlurper().parse(gebConfig)
configuration = new Configuration(rawGebConfig)

Browser.drive(configuration) {
go "http://......"
$("input[name=username]").value("username")
$("input[name=password]").value("password")
$("#loginButton").click()
waitFor() { $('.someClass') }
$("a", text: contains("SomeLink")).click()
waitFor() { $('#header', text: contains("Some Text")) }
}
  • You need to put all jars necessary to run PhantomJS in the 'ext' folder, not 'lib'.

    groovy-1.8.5 is already in the LoadUI classpath so you don't need to add it.

    Regards,

    Renato