Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save igormukhin/9d2e480bdf75534b227e to your computer and use it in GitHub Desktop.
Save igormukhin/9d2e480bdf75534b227e to your computer and use it in GitHub Desktop.
Geb configuration which tells Geb to reuse an already open Firefox window
/*
This is the Geb configuration file.
See: http://www.gebish.org/manual/current/configuration.html
*/
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.firefox.FirefoxProfile
import org.openqa.selenium.remote.DesiredCapabilities
import org.openqa.selenium.remote.RemoteWebDriver
// http://jira.codehaus.org/browse/GEB-130
def reuseExistingDriver = {
System.setProperty('webdriver.firefox.useExisting', 'true')
System.setProperty("webdriver.reap_profile", "false")
boolean isRunning
try {
final Socket socket = new Socket()
socket.connect(new InetSocketAddress("localhost", 7055))
socket.close()
isRunning = true
} catch (final IOException io) {
isRunning = false
}
def webDriver
if (!isRunning) {
final FirefoxProfile profile = new FirefoxProfile()
profile.setAlwaysLoadNoFocusLib(true)
profile.setEnableNativeEvents(true)
webDriver = new FirefoxDriver(profile)
} else {
try {
webDriver = new RemoteWebDriver(new URL("http://localhost:7055/hub"), DesiredCapabilities.firefox())
} catch (final Exception e) {
throw new RuntimeException(e)
}
}
return webDriver
}
cacheDriver = false
driver = reuseExistingDriver
baseUrl = "http://.../"
reportsDir = "target/geb-reports"
quitCachedDriverOnShutdown = false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment