Document Properties
Kbid
29U143
Last Modified
02-Dec-2022
Added to KB
18-Jul-2019
Public Access
Everyone
Status
Online
Doc Type
Guidelines
Product
ICM 7.10
Guide - 7.10.13.4 Update Assembly Geb Configuration

Table of Contents


Introduction

The version 2.0.1 of the versionfilter-icm-test component used to resolve dependencies to external libraries contains the following changes:

  • Updated Selenium libraries from 2.47.2(Sep 2015) to 3.141.59(Nov 2018) version
    • In the new Selenium version support for PhantomJSDriver has been dropped
  • Removed PhantomJSDriver-related libraries from the dependencies
  • Added new libraries for ParameterizedTest and Mockito extension for jupiter(JUnit5) to the dependencies

The main goal of these changes is to allow the execution of Geb tests with a real Firefox or Chrome browser, run in a headless mode.

Another goal is to remove PhantomJSDriver dependency as it is out of support. The reason why Selenium decided to drop the support for PhantomJS driver can be explained as follows:

  • PhantomJS developers claimed its EOL and recommended to use headless Firefox or Chrome. As soon as headless support was explicitly added to Selenium API, we decided to drop PhantomJS.
  • However, much more important is the fact that PhantomJS driver, also known as ghostdriver, has effectively been abandoned since 2014. There is no movement to make it conformant to W3C WebDriver standard. For that reason it is getting incompatible with Selenium as we are moving to a W3C driven future.

In case custom assemblies in customer projects require the execution of Geb tests, some migration of assembly Gradle files will be needed when upgrading from a version before 7.10.13.0 to ICM 7.10.13.0 or to a later version. Migration is done for the standard Intershop assemblies (intershop7, inspired-b2c, inspired-b2x).

Migration

Update the following Gradle files in the project of your assembly:

  • build.gradle
    • Remove dependencies to phantomjsdriver and webDrivers in Geb configuration
    • Add dependency to selenium-firefox-driver and support for geckoDriver in webDrivers in Geb Configuration
    • Set default webdriver for execution of Geb tests to be geckoDriver
  • src/remoteTest/resources/GebConfig.groovy
    • Remove import of phantomjsdriver classes and support for PhantomJsDriver in Geb environments
    • Add import of selenium.firefox classes and support for geckoDriver in Geb environments

Sample code blocks:

build.gradle
gebConfiguration {
    webDrivers {
        chromeDriver {
            environments {
                chromePC
                chromeTablet
            }

            download {
                linux {
                    url = 'http://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip'
                    archiveType = 'zip'
                    webDriverExec = 'chromedriver'
                }
                windows {
                    url = 'http://chromedriver.storage.googleapis.com/2.35/chromedriver_win32.zip'
                    archiveType = 'zip'
                    webDriverExec = 'chromedriver.exe'
                }
            }
        }

        geckoDriver {
            environments {
                geckoPC {check=true}
                geckoTablet
            }

            download {
                linux {
                    url = 'https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz'
                    archiveType = 'tar'
                    webDriverExec = 'geckodriver'
                }
                windows {
                    url = 'https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-win32.zip'
                    archiveType = 'zip'
                    webDriverExec = 'geckodriver.exe'
                }
            }
        }
    }
}
GebConfig.groovy
import org.openqa.selenium.Dimension
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.firefox.*
import org.openqa.selenium.remote.*

def gebEnv = System.getProperty("geb.env");
def webDriverDir = System.getProperty("webDriverDir")
def webDriverExec = new File(webDriverDir, System.getProperty("webDriverExec")).absolutePath

waiting {
	// max request time in seconds
    timeout = 180
    
    // http://gebish.org/manual/current/#failure-causes
    includeCauseInMessage = true
}

environments {

    chromeTablet {
        driver = {
            def driver = createChromeDriverInstance(webDriverExec)
            driver.manage().window().setSize(new Dimension(1024, 768))
            driver
        }
    }

    chromePC {
        driver = {
            def driver = createChromeDriverInstance(webDriverExec)
            driver.manage().window().setSize(new Dimension(1920, 1200))
            driver
        }
    }

    geckoPC {
        driver = {
            def driver = createGeckoDriverInstance(webDriverExec)
            driver.manage().window().setSize(new Dimension(1920, 1200))
            driver
        }
    }

    geckoTablet {
        driver = {
            def driver = createGeckoDriverInstance(webDriverExec)
            driver.manage().window().setSize(new Dimension(1024, 768))
            driver
        }
    }
}

private def createGeckoDriverInstance(String webDriverExec) {
    System.setProperty("webdriver.gecko.driver", webDriverExec)
    FirefoxOptions options = new FirefoxOptions()
    options.setHeadless(true)
    driverInstance = new FirefoxDriver(options)
    driverInstance
}

private def createChromeDriverInstance(String webDriverExec) {
    System.setProperty("webdriver.chrome.driver", webDriverExec)
    driverInstance = new ChromeDriver()
    driverInstance
}
In case your project runs Geb tests, ensure Firefox browser is installed on the machine where Geb tests are executed, as now the related geckoDriver is the default webdriver for the execution of Geb tests.

Now you can use the gebGeckoPCEnvironmentTest Gradle task (instead of gebPhantomJsPCEnvironmentTest) to execute Geb Tests in the assembly. Example:

> gradlew :<*assembly>:gebGeckoPCEnvironmentTest --tests *OrderSpec* -x deployServer -x buildSearchIndex -x startWebserver -x startNodemanager -x stopNodemanager -x stopWebserver -s

Disclaimer
The information provided in the Knowledge Base may not be applicable to all systems and situations. Intershop Communications will not be liable to any party for any direct or indirect damages resulting from the use of the Customer Support section of the Intershop Corporate Web site, including, without limitation, any lost profits, business interruption, loss of programs or other data on your information handling system.
The Intershop Knowledge Portal uses only technically necessary cookies. We do not track visitors or have visitors tracked by 3rd parties. Please find further information on privacy in the Intershop Privacy Policy and Legal Notice.
Home
Knowledge Base
Product Releases
Log on to continue
This Knowledge Base document is reserved for registered customers.
Log on with your Intershop Entra ID to continue.
Write an email to supportadmin@intershop.de if you experience login issues,
or if you want to register as customer.