Zalenium+Docker to run Serenity BDD tests

Hi There,
Can someone please help me in executing my Serenity BDD tests in a Docker container.I have tried using Zalenium to execute my tests but I am getting timeout exception.

2 Likes

@muchapathi Do you have logs with the error details and/or a stack trace you could share?

1 Like

Show us some code :stuck_out_tongue:

  • Are you getting a timeout on the tests or on something else?
  • How much memory do you use?
  • Are you running parallel tests?
1 Like

1.I have used the below to start Zalenium:

Pull docker-selenium

docker pull elgalu/selenium

# Pull Zalenium
docker pull dosel/zalenium

# Run it!
docker run --rm -ti --name zalenium -p 4444:4444 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /tmp/videos:/home/seluser/videos \
  --privileged dosel/zalenium start
  
# Point your tests to http://localhost:4444/wd/hub and run them

2.In my Serenity BDD framework -->serenity.config file I have included the below
webdriver {

driver = remote

remote {
url=“http://localhost:4444/wd/hub
driver=chrome
}

}
3.On executing the test cases i am getting below error:
net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class org.openqa.selenium.remote.RemoteWebDriver

at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:144)

at net.thucydides.core.webdriver.WebDriverFacade.newProxyDriver(WebDriverFacade.java:132)

at net.thucydides.core.webdriver.WebDriverFacade.getProxiedDriver(WebDriverFacade.java:102)

at net.thucydides.core.webdriver.WebDriverFacade.executeScript(WebDriverFacade.java:373)

at testcases.PositiveLoginTest.doLogin(PositiveLoginTest.java:42)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.base/java.lang.reflect.Method.invoke(Method.java:564)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

at net.serenitybdd.junit.runners.SerenityStatement.evaluate(SerenityStatement.java:33)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)

at net.serenitybdd.junit.runners.SerenityRunner.performRunChild(SerenityRunner.java:463)

at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:438)

at net.serenitybdd.junit.runners.SerenityRunner.runChild(SerenityRunner.java:45)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

at org.junit.runners.ParentRunner.run(ParentRunner.java:363)

at net.serenitybdd.junit.runners.SerenityRunner.run(SerenityRunner.java:242)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:542)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:770)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:464)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate new WebDriver instance of type class org.openqa.selenium.remote.RemoteWebDriver (Unable to create new remote session. desired capabilities = Capabilities {acceptInsecureCerts: false, browserName: chrome, chrome.switches: --disable-extensions,–user…, goog:chromeOptions: {args: [–disable-extensions, --user-agent=New User Agent], extensions: }, idle-timeout: 180, loggingPrefs: org.openqa.selenium.logging…, platform: ANY, record-screenshots: false, version: }

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

System info: host: ‘Swethas-MacBook-Pro.local’, ip: ‘2003:ea:b748:a3f0:c3f:ebd2:20ac:d2f%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘15.0.1’

Driver info: driver.version: DefaultRemoteDriver). See below for more details.

at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:158)

at net.thucydides.core.webdriver.WebDriverFacade.newDriverInstance(WebDriverFacade.java:141)

… 31 more

Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities {acceptInsecureCerts: false, browserName: chrome, chrome.switches: --disable-extensions,–user…, goog:chromeOptions: {args: [–disable-extensions, --user-agent=New User Agent], extensions: }, idle-timeout: 180, loggingPrefs: org.openqa.selenium.logging…, platform: ANY, record-screenshots: false, version: }

Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:17:03’

System info: host: ‘Swethas-MacBook-Pro.local’, ip: ‘2003:ea:b748:a3f0:c3f:ebd2:20ac:d2f%en0’, os.name: ‘Mac OS X’, os.arch: ‘x86_64’, os.version: ‘10.16’, java.version: ‘15.0.1’

Driver info: driver.version: DefaultRemoteDriver

at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:87)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)

at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:131)

at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:144)

at net.serenitybdd.core.webdriver.driverproviders.RemoteDriverBuilder.newRemoteDriver(RemoteDriverBuilder.java:55)

at net.serenitybdd.core.webdriver.driverproviders.DefaultRemoteDriver.buildWithOptions(DefaultRemoteDriver.java:24)

at net.serenitybdd.core.webdriver.driverproviders.RemoteDriverProvider.newInstance(RemoteDriverProvider.java:54)

at net.thucydides.core.webdriver.WebDriverFactory.createWebDriver(WebDriverFactory.java:169)

at net.thucydides.core.webdriver.WebDriverFactory.newWebdriverInstance(WebDriverFactory.java:150)

… 32 more

This is my first time with Dockers + Zalenium and not knowing if a session is created or not.Need help with it…

1 Like

Some extra questions/points:

  • What serenity-core version are you using?
  • If you use Firefox as a browser, do you get the same result?

I think (by googling) it might be a ChromeDriver issue: Make sure the chromedriver binary is compatible with the Chrome version (each version needs a different binary). This is something that pops up a lot on google while searching for issues like this.

1 Like

1.Serenity-core-2.0.81
2.I just check and i am getting : net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver

But if you think that it is chrome browser compatibility issue,I wonder what’s the point of remote driver execution.

1 Like

Could you try downgrading to Serenity-core 2.0.45 and see if that works?

Source: serenity-core 2.0.46 (and newer) + BrowserStack throws net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate class org.openqa.selenium.firefox.FirefoxDriver · Issue #1859 · serenity-bdd/serenity-core · GitHub

1 Like

On downgrading to Serenity core 2.0.45 , I am getting “missing artifact net.serenity-bdd:serenity-zalenium:jar:2.0.45”
I don’t think Zalenium is supported by older version of Serenetiy

Are you making sure that the path the the web driver is correct and accessible?

This part of the stack trace seems to be telling something along those lines:

Caused by: org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities {acceptInsecureCerts: false, browserName: chrome, chrome.switches: --disable-extensions,–user…, goog:chromeOptions: {args: [–disable-extensions, --user-agent=New User Agent], extensions: }, idle-timeout: 180, loggingPrefs: org.openqa.selenium.logging…, platform: ANY, record-screenshots: false, version: }

I am not sure on setting the remote driver path.I think it should be taken care by the grid that I am using.

I found here that the browser config should be matching the one for the grid.
Might be related to your issue, hopefully.

You could set the path in the environment variables maybe?

You could set the path in the environment variables maybe? ----Path for??

The location of your Chrome drivers pathing on the remote path. So it’s always accessible from anywhere.
Seen a few issues while googling about this topic also. It’s just guesswork right now :stuck_out_tongue:

1 Like

But why does it need the path in my local when I want to run my test cases on remote server?

It needs to be set on your remote server, maybe it’s not installed at the default location.

As per their official documentation : Running Serenity tests on a Selenium Grid :: The Serenity BDD Book
I dont think I need to set the path.

Hmm. Have you tried created a issue report on their github? This might be your next best option.