zoran119
zoran119

Reputation: 11307

How to set FirefoxDriver as the driver for Geb

This seems to work:

@Grapes([ 
    @Grab("org.codehaus.geb:geb-core:0.7.2"),
    @Grab("org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.25.0"),
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.25.0")
])

import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver

Browser.drive() {

    go "http://www.google.com"
}

But how do I use FirefoxDriver instead of HtmlUnitDriver? This just starts Firefox but all the drive instructions are executed in HtmlUnitDriver...

@Grapes([ 
    @Grab("org.codehaus.geb:geb-core:0.7.2"),
    @Grab("org.seleniumhq.selenium:selenium-htmlunit-driver:2.25.0"),
    @Grab("org.seleniumhq.selenium:selenium-support:2.25.0"),
    @Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.25.0")
])

import geb.Browser
import org.openqa.selenium.firefox.FirefoxDriver

def browser = new Browser(driver: new FirefoxDriver())

browser.drive {

    go "http://www.google.com"

}

Upvotes: 1

Views: 4093

Answers (3)

Sanjay Bharwani
Sanjay Bharwani

Reputation: 4759

We have done following configuration in the GebConfig.groovy to register FireFoxDriver with Geb.

driver = {
    def firefoxDriver = new FirefoxDriver()
    SharedResources.instance.browser = firefoxDriver
    firefoxDriver.manage().window().maximize()
    firefoxDriver
}

Hope that helps

Upvotes: 1

MariuszS
MariuszS

Reputation: 31567

Try this:

Browser.drive(new FirefoxDriver()) {

    // firefox 

}

Upvotes: 0

Matt Whipple
Matt Whipple

Reputation: 7134

Use a configuration script as outlined here: http://www.gebish.org/manual/0.7.0/configuration.html

Upvotes: 2

Related Questions