Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geb Configuration

Tags:

groovy

spock

geb

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.

like image 939
Scott Avatar asked Mar 13 '13 20:03

Scott


People also ask

What is Geb framework?

Geb is a Web automation framework using Groovy. Geb uses WebDriver to test web applications using either real browsers or the HtmlUnit library.

What is Geb in automation?

Geb is a browser automation solution. It can be used for scripting, scraping and general automation — or equally as a functional/web/acceptance testing solution via integration with testing frameworks such as Spock or JUnit. Spock. Spock is a testing and specification framework for Java and Groovy applications.

What is Geb tool?

Geb is a free, open-sourced tool. It is licensed under the Apache License, Version 2.0. Easy and simple to automate web testing. Geb's Page Objects and Groovy DSL make tests readable to the extent that they almost look like plain English. Runs the tests fast and thus saves the time and cost of testing.


1 Answers

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
like image 153
Scott Avatar answered Oct 23 '22 12:10

Scott