Skip to content

Commit

Permalink
Use (somewhat overwrought) method of conditionally making driver head…
Browse files Browse the repository at this point in the history
…less
  • Loading branch information
jonnybot0 committed Dec 23, 2024
1 parent 4124f12 commit a35598d
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package configuration
import geb.driver.CachingDriverFactory
import geb.fixture.HeadlessTestSupport
import geb.test.StandaloneWebDriverServer
import org.junit.jupiter.api.Assumptions
import org.openqa.selenium.firefox.FirefoxDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.openqa.selenium.remote.RemoteWebDriver
Expand All @@ -38,16 +37,24 @@ class DriverConfigSpec extends Specification implements InlineConfigurationLoade

def setupSpec() {
CachingDriverFactory.clearCacheAndQuitDriver()
Assumptions.assumeFalse(HeadlessTestSupport.headless)
}

def "configuring driver using closure"() {
when:
// lang=groovy
configScript """
import org.openqa.selenium.firefox.FirefoxOptions
// tag::configuring_driver[]
// tag::configuring_driver-a[]
import org.openqa.selenium.firefox.FirefoxDriver
driver = { new FirefoxDriver() }
driver = {
new FirefoxDriver()
// end::configuring_driver-a[]
${HeadlessTestSupport.headless ? /new FirefoxDriver(new FirefoxOptions().addArguments('--headless'))/ : ''}
// tag::configuring_driver-b[]
}
// end::configuring_driver-b[]
// end::configuring_driver[]
"""

Expand Down Expand Up @@ -129,4 +136,4 @@ class DriverConfigSpec extends Specification implements InlineConfigurationLoade
null | HtmlUnitDriver
"remote" | RemoteWebDriver
}
}
}

0 comments on commit a35598d

Please sign in to comment.