{GebConfig.groovy} How do the configuration of driver and baseUrl are called form GebConfig.groovy.

833 views
Skip to first unread message

ADITYA GAURAV

unread,
Feb 22, 2017, 2:27:55 PM2/22/17
to Geb User Mailing List
Hi,

Recently, I moved to Geb. In the project, there is a groovy class named as 'GenConfig.groovy'. In this class, we set our driver and browser configuration. I have few observations.

1.How does 'build.gradle' use this class?
2.In my project, we are not calling this from any of the classes as per my knowledge then how does driver open the URL that is mention in this class.  As I know in Geb we mention our baseUrl that is being called by the browser.
3. Or from somewhere internally Geb is calling this on driver instance.

This question came out when I have created a new project for my practice. That project is the combination of "Geb+Spock+Gradle". In that, I have created "GebConfig.groovy" class and provided all the required configurations of driver and baseUrl. Then I simply wrote a  groovy class to open a browser and perform some activity. But when I ran the program nothing happened. It didn't open the browser. So how do I use that GebConfig.groovy in our project to make it work. Do I need to make any changes in my 'build.gradle'?




Thanks,
Aditya  


Marcin Erdmann

unread,
Feb 24, 2017, 9:45:38 AM2/24/17
to geb-...@googlegroups.com
Hi Aditya,

When you say that nothing happened does that mean that execution hanged or did you get an exception? When you say you run the programm, do you mean that you are running a specification extending from GebSpec?

Gradle does not know anything about Geb's config and thus build.gradle does not call the GebConfig script. It is automatically loaded and executed by Geb via the ConfigurationLoader class when instantiating a Browser (https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/Browser.groovy#L61). This happens as long as there is a GebConfig.groovy script available as a resource on the classpath or there is a class called GebConfig available on the classpath.

Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/b07a610e-73bb-4566-9e01-b85817bba078%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ADITYA GAURAV

unread,
Feb 26, 2017, 3:13:35 PM2/26/17
to Geb User Mailing List
Hi Marcin,

Thank you so much for giving me an update. After so many trials, I have successfully set up my project and "The Book Of Geb" helped me a lot. 

Thanks,
Aditya

On Friday, 24 February 2017 06:45:38 UTC-8, Marcin Erdmann wrote:`
Reply all
Reply to author
Forward
0 new messages