/selenide-maven-sample

Sample Maven project with Selenide tests

Primary LanguageJavaApache License 2.0Apache-2.0

Maven Selenide Tests

Build Status

This is an example of how you can run Selenium tests with Selenide under maven. See my blog post with explainations.

Use maven 3.3+ and JDK 1.8 to run the tests Default maven goal is "clean test", default browser is "firefox".

Command line:

mvn

In case of failure, Selenide create screenshots at ${basedir}/build

Use different browsers

Specify maven profile to use different browsers

mvn test -P<browser>

where browsers are:

  • chrome
  • firefox
  • phantomjs
  • ie

Testing with Chrome

  1. Download and install chromedriver to directory ${HOME}/bin

  2. Run maven: mvn test -Pchrome

You may override the chromedriver path by passing system property to maven:

mvn test -chrome -Dwebdriver.gecko.driver=<path-to>/chromedriver

Testing with Firefox

Download geckodriver and install it to ${HOME}/bin

The Selenium client bindings will try to locate the geckodriver executable from the system path. But it may not work. So using system property webdriver.gecko.driver is the most stable solution. Original referene: Firefox Marionette WebDriver

You may override the geckodriver path by passing system property to maven:

mvn test -Pfirefox -Dwebdriver.gecko.driver=<path-to>/geckodriver

Testing with Safari

  1. Start Safari and select 'Allow Remote Automation' option in Safari's Develop menu. Otherwise you'll see the following message in logs:

     "Could not create a session: You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control"
    
  2. Run maven: mvn test -Psafari

Leave browser open after test

If selenide property holdBrowserOpen is true, browser window stays open after running tests. It may be useful for debugging. Can be configured either programmatically or by system property -Dselenide.holdBrowserOpen=true.

To activate this property use maven profile "local":

mvn test -P<browser>,local

Running in Selenium Grid

Selenium grid URL: http://jenkins.fxpro.local:4444/grid (monitoring) Selenium Hub Url: http://jenkins.fxpro.local:4444/wd/hub (to conenct to)

Specify profile "jenkins" in addition to browser profile to use with selenium hub.

# Remote chrome
mvn -Pci-server,chrome

# Remote firefox
mvn -Pci-server,firefox

Specify parameter selenium.hub.url to override, e.g:

mvn clean test -Pci-server -Dselenium.hub.url=http://localhost:4444/wd/hub