how to use geb-browserstack plugin?

552 views
Skip to first unread message

medv...@gmail.com

unread,
Nov 3, 2017, 8:36:00 AM11/3/17
to Geb User Mailing List
hi,
how could I use the browserstack integration in geb?

my current implementation for remotedrivers looks like this https://gist.github.com/rnemeth1980/ab0f707977862718ebeaa855102fd369

"remoteChromeDockerTest --tests *.login.LoginTest" is my sample gradle task. 

Can I define environments like "remoteChromeDocker" and use capabilities?

I do not see how I can fit the geb-browserstack plugin in there from here http://www.gebish.org/manual/current/#geb-browserstack-plugin.

thank you very much,
Roland

Marcin Erdmann

unread,
Nov 5, 2017, 11:44:04 AM11/5/17
to Geb User Mailing List
Roland,

The plugin has been introduced so that you don't have to manage opening and closing of the BrowserStack tunnel, define envs and use capabilities. There are also ways to customise what the plugin does, by for example not using the BrowserStackDriverFactory in your GebConfig.groovy or passing additional capabilities to its create() method.

You will need to be more specific about what you mean by fitting geb-browserstack plugin into what you have. If all you're after is setting some chrome options and capabilities when running in BrowserStack then it is of course possible and I can provide an example of how to do it.

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+unsubscribe@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/d0d6bad7-cb50-43b7-8191-7dd63cda43c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

medv...@gmail.com

unread,
Nov 6, 2017, 5:05:12 AM11/6/17
to Geb User Mailing List
Hello Marcin,

I would be very happy to see examples. My goal is to run one testspec a time on specific browser setups for having bamboo build plans for each browser setup.

How should add browserstack that I can start gradle tasks like this: "remoteChromeDockerTest --tests *.login.LoginTest" ( like in my current approach https://gist.github.com/rnemeth1980/ab0f707977862718ebeaa855102fd369) ?

This code here https://github.com/browserstack/geb-browserstack/blob/master/build.gradle seems to be different too. Is this approach still working?

Thank you very much for your help,
Roland

On Sunday, November 5, 2017 at 5:44:04 PM UTC+1, Marcin Erdmann wrote:
Roland,

The plugin has been introduced so that you don't have to manage opening and closing of the BrowserStack tunnel, define envs and use capabilities. There are also ways to customise what the plugin does, by for example not using the BrowserStackDriverFactory in your GebConfig.groovy or passing additional capabilities to its create() method.

You will need to be more specific about what you mean by fitting geb-browserstack plugin into what you have. If all you're after is setting some chrome options and capabilities when running in BrowserStack then it is of course possible and I can provide an example of how to do it.

Marcin
On Fri, Nov 3, 2017 at 12:36 PM, <medv...@gmail.com> wrote:
hi,
how could I use the browserstack integration in geb?

my current implementation for remotedrivers looks like this https://gist.github.com/rnemeth1980/ab0f707977862718ebeaa855102fd369

"remoteChromeDockerTest --tests *.login.LoginTest" is my sample gradle task. 

Can I define environments like "remoteChromeDocker" and use capabilities?

I do not see how I can fit the geb-browserstack plugin in there from here http://www.gebish.org/manual/current/#geb-browserstack-plugin.

thank you very much,
Roland

--
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.

Marcin Erdmann

unread,
Nov 6, 2017, 5:08:39 PM11/6/17
to Geb User Mailing List
Can you please expand on what you mean by "specific browser setups"? Which browsers (including which operating systems and versions) do you want to run your tests at BrowserStack?

The tasks added to the build by geb-browserstack plugin are regular org.gradle.api.tasks.testing.Test tasks which means that they support the --tests switch so you can run a single spec if you wish to.

The project from browserstack org on github you linked to will probably work but is overcomplicated because it aims to to run tests on multiple browsers at BrowserStack concurrently.

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

medv...@gmail.com

unread,
Nov 7, 2017, 2:32:47 AM11/7/17
to Geb User Mailing List
I would like to test these os/browser combinations:

OS

Browser

Windows 10 (64-bit)

EDGE

Windows 8.1 (64-bit)

Firefox

Windows 7 (64-bit)

IE11

macOS High Sierra

Safari


Do I need to care about browser versions except for IE? Browserstack takes care of the driver I assume. As far as I understand Geb 2.0 supports Selenium 3.6.0, but I am unsure if I can take the latest browser versions for e.g. Safari or EDGE.

Thank you very much!


Marcin Erdmann

unread,
Nov 7, 2017, 2:44:38 PM11/7/17
to Geb User Mailing List
In your build file:

apply plugin: "geb-browserstack" 

buildscript { 
    repositories {
       mavenCentral()
    }
    dependencies {
       classpath 'org.gebish:geb-gradle:2.0'
    }
}

browserStack {
    application 'http://localhost:8080' //change to point at the app you're testing

    browsers {
        firefox {
            capabilities os: "WINDOWS", os_version: "8.1"
        }
        edge {
             capabilities os: "WINDOWS", os_version: "10"
        }
        safari {
              capabilities os: "OS X", os_version: "High Sierra"
        }
        create("internet explorer") {
              capabilities os: "WINDOWS", os_version: 7", browser_version: "11"
        }
    }
    account {
        username = System.getenv("GEB_BROWSERSTACK_USERNAME") //ensure the environment vars are populated
        accessKey = System.getenv("GEB_BROWSERSTACK_AUTHKEY") //ensure the environment vars are populated
    }
}

at the top of your GebConfig:

def browserStackBrowser = System.getProperty("geb.browserstack.browser")
if (browserStackBrowser) {
    driver = {
        def username = System.getenv("GEB_BROWSERSTACK_USERNAME")
        assert username
        def accessKey = System.getenv("GEB_BROWSERSTACK_AUTHKEY")
        assert accessKey
        new BrowserStackDriverFactory().create(browserStackBrowser, username, accessKey)
    }
}

then running your tests:

gradle firefoxTest --tests *.login.LoginTest
gradle edgeTest --tests *.login.LoginTest
gradle safariTest --tests *.login.LoginTest
gradle internetExplorerTest --tests *.login.LoginTest

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

medv...@gmail.com

unread,
Nov 8, 2017, 10:05:45 AM11/8/17
to Geb User Mailing List
It is simply perfect! Thank you very much Marcin for all your help! 
Message has been deleted

medv...@gmail.com

unread,
Dec 7, 2017, 6:20:32 AM12/7/17
to Geb User Mailing List
Hi Marcin,

I have access now to browserstack to try out the your code actually.

The way the baseUrl is set does not work.


I tried this

String baseUrl = System.getProperty("functional.tests.baseurl")

if(baseUrl) {
 println
("functional.tests.baseurl -> $baseUrl")
}

application baseUrl

and also hardcoding the url, but get this exception:

geb.error.NoBaseUrlDefinedException: There is no base URL configured and it was requested. Please see the Geb manual for different ways of managing the base URL (quick solution: you can set the 'geb.build.baseUrl' JVM system property)


Could you please help me?

Thank you very much in advance,
Roland

medv...@gmail.com

unread,
Dec 7, 2017, 8:53:38 AM12/7/17
to Geb User Mailing List
I tried 

browserStack {


 
String baseUrl = System.getProperty("functional.tests.baseurl")

 
if(baseUrl) {
 println
("functional.tests.baseurl -> $baseUrl")


 systemProperty
"geb.build.baseUrl", baseUrl
 
}

 application baseUrl

 browsers
{

but get 

* What went wrong:
A problem occurred evaluating root project
'functional-tests-...'.
> Could not find method systemProperty() for arguments [geb.build.baseUrl, https://www.....com/] on root project 'functional-tests-...'.

Any idea what I am doing wrong?

Thank you in advance!

Marcin Erdmann

unread,
Dec 7, 2017, 3:04:34 PM12/7/17
to Geb User Mailing List
You need to do the following:

browserStack {
    task {
        systemProperty "geb.build.baseUrl", baseUrl
    }
}


To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

medv...@gmail.com

unread,
Dec 8, 2017, 8:51:01 AM12/8/17
to Geb User Mailing List
This works perfectly.

Thank you very much Marcin for your help! 

medv...@gmail.com

unread,
Dec 8, 2017, 11:54:47 AM12/8/17
to Geb User Mailing List
Hi Marcin,

May I ask you another question?

I have this in my build.gradle

browsers {
 firefox
{
 capabilities os
: "WINDOWS", os_version: "8.1"
 
}
 edge
{
 capabilities os
: "WINDOWS", os_version: "10"
 
}
 safari
{
 capabilities os
: "OS X", os_version: "High Sierra"
 
}
 create
("internet explorer") {
 capabilities os
: "WINDOWS", os_version: "7", browser_version: "11"
 
}
}

gradle firefoxTest --tests *.login.LoginTest
gradle edgeTest --tests *.login.LoginTest
gradle safariTest --tests *.login.LoginTest
gradle internetExplorerTest --tests *.login.LoginTest

these above work fine, but how do I specify testing tasks e.g. for firefox for more browsers?
firefox on win7 and firefox on mac?

I read about the shorthand syntax here http://gebish.org/manual/current/#geb-browserstack-plugin
point 5 - but how does this work? is it listed somewhere what is accepted?

Thank you very much in advance!

Best regards,
Roland

Marcin Erdmann

unread,
Dec 9, 2017, 6:31:34 AM12/9/17
to Geb User Mailing List
The capabilities available in BrowserStack are listed at https://www.browserstack.com/automate/capabilities.

With regards to the shorthand syntax, the parts separated by an underscore are mapped in the following order (refer to the link I provided for values allowed for each capability):
- browserName capability
- platform capablity
- version capability

So firefox_windows_47 means Firefox version 47 on any version of Windows. And then you can specify additional capabilities like the OS version the way I showed you before using a capabilities call inside of the closure specified for a given browser.

With regards to adding multiple test tasks for firefox:

browsers {
    firefox_mac 
    firefox_win8  {
        platform: "WINDOWS", os_version: "8.1"
    }
    firefox_win7 {
        platform: "WINDOWS", os_version: "7"
    }
}

gradle firefoxMacTest --tests *.login.LoginTest
gradle firefoxWin8Test --tests *.login.LoginTest
gradle firefoxWin7Test --tests *.login.LoginTest

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

medv...@gmail.com

unread,
Dec 11, 2017, 3:49:00 AM12/11/17
to Geb User Mailing List
Hi Marcin,

I tried the following as you wrote


but it shows an error in intellij already, and an error during compilation:

164: unexpected token: WINDOWS @ line 164, column 23.

               platform
: "WINDOWS", os_version: "8.1"

                         
^

Then I tried

but this gives me an error during compliation 

169: Statement labels may not be used in build scripts.
In case you tried to configure a property named 'os_version', replace ':' with '=' or ' ', otherwise it will not have the desired effect.
 
@ line 169, column 25.
               os_version
: "10"
                           
^

Could you please help me?

Thank you very much in advance,
Roland

Marcin Erdmann

unread,
Dec 11, 2017, 4:04:08 AM12/11/17
to Geb User Mailing List
Sorry, my bad. Should be:

browsers {
    firefox_mac 
    firefox_win8  {
        capabilities platform: "WINDOWS", os_version: "8.1"
    }
    firefox_win7 {
        capabilities platform: "WINDOWS", os_version: "7"
    }
}

To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.

medv...@gmail.com

unread,
Dec 11, 2017, 7:42:05 AM12/11/17
to Geb User Mailing List
I tried

firefox_win8 {
 capabilities platform
: "WINDOWS", os_version: "8.1"
}

by running this way

firefoxWin8Test --tests *Basic_Search_Test*

and got this error:


    geb.driver.DriverCreationException: failed to create driver from callback 'script151299489270595963650$_run_closure2@397ecee3'


       
Caused by:
        java
.lang.reflect.InvocationTargetException


           
Caused by:
            org
.openqa.selenium.WebDriverException: Error : Platform and OS Version cannot be passed together. (WARNING: The server did not provide any stacktrace information)
           

I also tried 

edge_win10 {
 capabilities platform
: "WINDOWS", os_version: "10"
}


by running this way

edgeWin10Test --tests *Basic_Search_Test*

and got the same error as before:

    geb.driver.DriverCreationException: failed to create driver from callback 'script151299565014195963650$_run_closure2@19b0ec6c'


       
Caused by:
        java
.lang.reflect.InvocationTargetException


           
Caused by:
            org
.openqa.selenium.WebDriverException: Error : Platform and OS Version cannot be passed together. (WARNING: The server did not provide any stacktrace information)

Could you please let me know what I am doing wrong?

How do I use proxies with browserstack?

Currently I use proxies for docker and VMs this way:

Proxy proxy = new Proxy();
proxy
.setHttpProxy("proxy-123.de");
proxy
.setSslProxy("proxy-123.de");
proxy
.setNoProxy("127.0.0.1,localhost,selenium");
caps
.setCapability(CapabilityType.PROXY, proxy);


browserStack {
    account
{
        proxyHost
= '127.0.0.1'
        proxyPort
= '8080'
        proxyUser
= 'user'
        proxyPass
= 'secret'
   
}
}


but do not know how to set http, ssl and noproxy for browserstack.

Thank you very much,
Roland

Marcin Erdmann

unread,
Dec 11, 2017, 5:38:55 PM12/11/17
to Geb User Mailing List
Ok, I did not know that you cannot use platform and os version together on BrowserStack. Please use the following then:

browsers {
    firefox_mac 
    firefox_win8  {
        capabilities platform: null, os: "WINDOWS", os_version: "8.1"
    }
    firefox_win7 {
        capabilities platform: null, os: "WINDOWS", os_version: "7"
    }
    edge_win10 {
        capabilities platform: null, os: "WINDOWS", os_version: "10"
    }
}


To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.

To post to this group, send email to geb-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages