Geb Configuration
Asked Answered
V

1

8

This seems like it should be pretty straightforward, but I am not seeing how to get access to values in my GebConfig.groovy file. I've tried the following:

userName = "myUserName"

properties = {
  userName = "myUserName"
}

props {
  userName = "myUserName"
}

environments {
  chrome = { 
    driver = { new ChromeDriver() }
    userName = "myUserName" //with and without {}
  }
}

Yet I still can't seem to access these properties through:

browser.driver.properties.userName

Am I able to set those properties in the configuration file, and then access them in my spec? I seem to be getting the default set of properties, which is simply the System properties.

Viewer answered 13/3, 2013 at 20:5 Comment(2)
Did you really try browser.driver.properties (rather than browser.config.properties), or is this just a typo?Chronologist
It was a simply a typo.Viewer
V
9

This was rather quite simple, however I was making the problem much harder than it should have been. I couldn't see the forest for the trees.

I noticed that in the Configuration class, items from the rawConfig were being grabbed from the readValue method(s). The getRawConfig was also not showing up in the outline or in the configuration sources, leading me to skip right over attempting to access it directly.

browser.getConfig().getRawConfig().get("userName")

Or in a more groovy like fashion:

browser.config.rawConfig.userName
Viewer answered 14/3, 2013 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.