groovyautomationautomated-testsgeb

GEB: set default environment?


I declared a few environments in GebConfig via environments {} closure. And if I specify -Dgeb.env in command line, everything works perfectly.

But when I start a single test for debugging purposes, I don't want to explicitly pass any additional environment variables.

What is the way to define the environment to be used by GEB as a default?


Solution

  • Just define a default driver outside of the environments My Geb config looks like this:

    driver = {
      new HtmlUnitDriver(true)
    }
    
    environments {
      html_unit {
        driver = {
          new HtmlUnitDriver(true)
        }
      }
      phantomjs {
        driver = {
          WebDriverManager.phantomjs().version("2.1.1").setup()
          def pjsDriver = new PhantomJSDriver()
          pjsDriver.manage().window().size = new Dimension(1024, 768)
          pjsDriver
        }
      }
      chrome {
        driver = {
          // (...)
        }
      }
      chrome_headless {
        System.setProperty("webdriver.chrome.logfile", "chromedriver.log")
        System.setProperty("webdriver.chrome.verboseLogging", "true")
        driver = {
          // (...)
        }
      }
      firefox {
        driver = {
          // (...)
        }
      }
      ie {
        driver = {
          // (...)
        }
      }
      edge {
        driver = {
          // (...)
        }
      }
      opera {
        driver = {
          // (...)
        }
      }
      win_app {
        driver = {
          // (...)
        }
      }
    }