Rob, you can refer to the geb-example-gradle project here:
https://github.com/geb/geb-example-gradle
This should provide you with your answer.
On Monday, April 22, 2019 at 11:22:55 PM UTC-5, Rob Powell wrote:
>
> Hello;
>
> Is it possible to have a complete all-in-one geb script that includes
> browser driver configuration?
>
> I have the following as GebExample.groovy:
> @Grapes([
> @Grab("org.gebish:geb-core:2.3.1"),
> @Grab(group='io.github.bonigarcia', module='webdrivermanager',
> version='3.4.0'),
> @Grab(group='org.seleniumhq.selenium',
> module='selenium-chrome-driver', version='3.141.0'),
> @Grab(group='org.seleniumhq.selenium', module='selenium-support',
> version='3.141.0')
> ])
>
> import io.github.bonigarcia.wdm.WebDriverManager
> import org.openqa.selenium.chrome.ChromeDriver
> import org.openqa.selenium.chrome.ChromeOptions
> import org.openqa.selenium.remote.DesiredCapabilities
> import geb.Browser
>
> WebDriverManager.chromedriver().setup();
>
> Browser.drive {
> go "http://gebish.org"
>
> assert title == "Geb - Very Groovy Browser Automation"
>
> $("div.menu a.manuals").click()
> waitFor { !$("#manuals-menu").hasClass("animating") }
>
> $("#manuals-menu a")[0].click()
>
> assert title.startsWith("The Book Of Geb")
> }
>
> If I have a GebConfig.groovy file in the same directory that has the
> following:
> import org.openqa.selenium.chrome.ChromeDriver
> import org.openqa.selenium.chrome.ChromeOptions
> driver = {
> ChromeOptions o = new ChromeOptions()
> o.addArguments('headless')
> new ChromeDriver(o)
> }
>
> Then the script runs as headless chrome.
>
> How do I get the config info into the single GebExample.groovy?
>
> ----
>
> I was exploring using the following, but it did not run as headless chrome:
> @Grapes([
> @Grab("org.gebish:geb-core:2.3.1"),
> @Grab(group='io.github.bonigarcia', module='webdrivermanager',
> version='3.4.0'),
> @Grab(group='org.seleniumhq.selenium',
> module='selenium-chrome-driver', version='3.141.0'),
> @Grab(group='org.seleniumhq.selenium', module='selenium-support',
> version='3.141.0')
> ])
>
> import io.github.bonigarcia.wdm.WebDriverManager
> import org.openqa.selenium.chrome.ChromeDriver
> import org.openqa.selenium.chrome.ChromeOptions
> import org.openqa.selenium.remote.DesiredCapabilities
> import geb.Browser
>
> WebDriverManager.chromedriver().setup();
>
> driver = {
> ChromeOptions o = new ChromeOptions()
> o.addArguments('headless')
> new ChromeDriver(o)
> }
>
> Browser.drive {
> go "http://gebish.org"
>
> assert title == "Geb - Very Groovy Browser Automation"
>
> $("div.menu a.manuals").click()
> waitFor { !$("#manuals-menu").hasClass("animating") }
>
> $("#manuals-menu a")[0].click()
>
> assert title.startsWith("The Book Of Geb")
> }
>
> Thoughts?
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/geb-user/efd01d76-cc51-4d83-8f8b-c3e89f3e940e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.