I really liked the idea of a standalone script running Geb. My main use
case would be to automate initial steps for a manual test (e.g. register a
user account in a certain way, fill test shopping cart etc.).
So I took today to refine the code a bit. Mixed in some PicoCLI goodness et
voilĂ : https://gist.github.com/mkutz/58d3ae2f07c8c519c8900ab5b25f5e87

Am Do., 25. Apr. 2019 um 03:39 Uhr schrieb Rob Powell <
[email protected]>:

> Thank you Marcin!
>
> Here is the complete example that works for me:
> @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.Configuration
> import geb.Browser
>
> WebDriverManager.chromedriver().setup();
>
> def configuration = new Configuration(
>     driver: {
>         ChromeOptions o = new ChromeOptions()
>         o.addArguments('headless')
>         new ChromeDriver(o)
>     }
> )
>
> Browser.drive(configuration) {
>     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")
> }
>
>
>
> On Wednesday, April 24, 2019 at 10:18:05 AM UTC-7, Marcin Erdmann wrote:
>>
>> The easiest way to achieve what you're after would probably be the
>> following:
>>
>> import geb.Configuration
>>
>> def configuration = new Configuration(
>>     driver: {
>>         ChromeOptions o = new ChromeOptions()
>>         o.addArguments('headless')
>>         new ChromeDriver(o)
>>     }
>> )
>>
>> Browser.drive(configuration) {
>>     ....
>> }
>>
>> On Tue, Apr 23, 2019 at 5:22 AM Rob Powell <[email protected]> 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/26f740de-6432-4606-b56c-fedf4acb06be%40googlegroups.com
>>> <https://groups.google.com/d/msgid/geb-user/26f740de-6432-4606-b56c-fedf4acb06be%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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/df908165-2224-4c72-8177-a96cc42b5a82%40googlegroups.com
> <https://groups.google.com/d/msgid/geb-user/df908165-2224-4c72-8177-a96cc42b5a82%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALYktxOCw-5CEG2evpQgch2kVYon4jMvfZch%3DPYwW8eSzsywOw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to