TestProject Forum

BBD cucumber project with java and maven

I am working on a POC to use testproject opensdk in my project.
I have configured my project using Java opensdk using Maven dependencies and cucumber framework and its working great.
Now, I want to setup docker agent and perform parallel execution of my Cucumber features/scenarios (or any other way that’s possible). Please help me with this.

Thanks.

Hello @shivam
it is quite simple, you mainly need to follow Cucumber guide for parallel execution:
https://cucumber.io/docs/guides/parallel-execution/

While using docker compose and the TestProject agent on docker to have X agent containers running in parallel.

Here is a link to an example POC I made which you can run: GitHub - Rantzur1992/parallel-cucumber: Example Tests with parallel execution on Docker using TestProject Java SDK and Docker

It’s quite simple, all you need is to start up the docker compose and replace $TP_API_KEY with your API key which you can get from here: TestProject

If you take a look at the yml file, you will see I have 2 services, each are an agent container that will run, each will run a feature file in parallel.

version: "3.1"

services:

  testproject-agent-1:

    image: testproject/agent:latest

    container_name: testproject-agent-1

    depends_on:

      - chrome

      - firefox

    environment:

      TP_API_KEY: $TP_API_KEY

      TP_SDK_PORT: "8686"             # Agent will listen on port 8686 for SDK connections

      CHROME: "chrome:4444"           # Address for Agent to communicate with Chrome browser

      CHROME_EXT: "localhost:5555"    # Address for accessing the Chrome Selenium server

      FIREFOX: "firefox:4444"         # Address for Agent to communicate with Firefox browser

      FIREFOX_EXT: "localhost:5556"   # Address for accessing the Firefox Selenium server

    ports:

        - "8585:8585"

        - "8686:8686"                     # Expose port for SDK<->Agent communication

  testproject-agent-2:

    image: testproject/agent:latest

    container_name: testproject-agent-2

    depends_on:

        - chrome

        - firefox

    environment:

        TP_API_KEY: $TP_API_KEY

        TP_SDK_PORT: "8787"             # Agent will listen on port 8686 for SDK connections

        CHROME: "chrome:4444"           # Address for Agent to communicate with Chrome browser

        CHROME_EXT: "localhost:5555"    # Address for accessing the Chrome Selenium server

        FIREFOX: "firefox:4444"         # Address for Agent to communicate with Firefox browser

        FIREFOX_EXT: "localhost:5556"   # Address for accessing the Firefox Selenium server

    ports:

        - "8888:8585"

        - "8787:8686"                     # Expose port for SDK<->Agent communication

  chrome:

    image: selenium/standalone-chrome

    volumes:

        - /dev/shm:/dev/shm

    ports:

    - "5555:4444"                     # Expose Selenium on port 5555

  firefox:

    image: selenium/standalone-firefox

    volumes:

      - /dev/shm:/dev/shm

    ports:

    - "5556:4444"                     # Expose Selenium on port 5556

You can see I designate each container a port to be used and an SDK port.

The Agent port will be provided in the code of the test, you can see in each feature file I direct each test to a different agent URL, that means, each test will run on a different agent container.

At the end, the containers will run, each test will be set to run on a different container, and they will run in parallel.

If you wish to add more feature files to be ran in parallel, just add the feature file in your code, and add another agent container, with a different port, inside the feature file, point that feature to run on the new container.

image

Hi @ran.tzur ,
Thanks for all the help.
I tried the implementing the code you sent. I got following errors(happens same when I execute the sample code you provided):

  1. When starting the agent through the docker-compose file
2021-05-10 16:13:15.241 [ERROR] i.t.a.m.c.b Failed to get external CHROME version via: http://chrome:4444/wd/hub
  1. Since, agent was able to download firefox drivers so, I tried executing my code for firefox using:
public static WebDriver driver;
driver = new FirefoxDriver(new URL("http://localhost:" + port), new FirefoxOptions(), "Cucumber");

Then I got this error message:

io.testproject.sdk.internal.exceptions.InvalidTokenException: No token has been provided.

FYI, I added my api token to docker-compose.yml file.
Could you please help me to solve these issue?

Regarding the developer token, you have two options:

  1. Enter your dev token inside the constructor of the driver in code.
  2. Set TP_DEV_TOKEN environment variable.

Regarding the Chrome container issue, it could be because you have an existing container which causes a conflict, try removing any existing chrome containers you have and run docker-compose again.

If we do this, then we cannot enter the URL. So, I believe this won’t help. Or is there any other workaround ?

Tried this, doesn’t help!

A better solution will be using DriverBuilder to not get tangled with complex constructors.

driver = new DriverBuilder<FirefoxDriver>(new FirefoxOptions())
        .withRemoteAddress(new URL("http://localhost:" + "port"))
        .withProjectName("Cucumber")
        .withToken("YOUR DEV TOKEN")
        .build(FirefoxDriver.class);

Also, after setting TP_DEV_TOKEN you need to restart your system for the environment variable to take affect.

I removed all the container and ran docker-compose again, Still getting same error!!

Can you post the full output of the agent containers please

Chrome container:

2021-05-11 06:48:41,496 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing

2021-05-11 06:48:41,500 INFO supervisord started with pid 9

2021-05-11 06:48:42,504 INFO spawned: 'xvfb' with pid 11

2021-05-11 06:48:42,506 INFO spawned: 'selenium-standalone' with pid 12

06:48:42.935 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358

2021-05-11 06:48:42,938 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-05-11 06:48:42,938 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

06:48:43.236 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444

2021-05-11 06:48:43.372:INFO::main: Logging initialized @849ms to org.seleniumhq.jetty9.util.log.StdErrLog

06:48:44.140 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet

06:48:44.485 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

06:49:05.014 INFO [ActiveSessionFactory.apply] - Capabilities are: {

"browserName": "chrome",

"goog:chromeOptions": {

"args": [

],

"extensions": [

]

}

}

06:49:05.014 INFO [ActiveSessionFactory.apply] - Capabilities are: {

"browserName": "chrome",

"goog:chromeOptions": {

"args": [

],

"extensions": [

]

}

}

06:49:05.017 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

06:49:05.017 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

Starting ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}) on port 7854

Only local connections are allowed.

Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.

ChromeDriver was started successfully.

[1620715745.082][SEVERE]: bind() failed: Cannot assign requested address (99)

Starting ChromeDriver 90.0.4430.24 (4c6d850f087da467d926e8eddb76550aed655991-refs/branch-heads/4430@{#429}) on port 9874

[1620715745.080][SEVERE]: bind() failed: Cannot assign requested address (99)

Only local connections are allowed.

Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.

ChromeDriver was started successfully.

Firefox Container:

2021-05-11 06:48:41,626 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing

2021-05-11 06:48:41,629 INFO supervisord started with pid 8

2021-05-11 06:48:42,632 INFO spawned: 'xvfb' with pid 10

2021-05-11 06:48:42,634 INFO spawned: 'selenium-standalone' with pid 11

06:48:43.281 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358

2021-05-11 06:48:43,292 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

2021-05-11 06:48:43,292 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)

06:48:43.555 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444

2021-05-11 06:48:43.653:INFO::main: Logging initialized @1003ms to org.seleniumhq.jetty9.util.log.StdErrLog

06:48:44.462 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet

06:48:44.645 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444

06:49:06.480 INFO [ActiveSessionFactory.apply] - Capabilities are: {

"acceptInsecureCerts": true,

"browserName": "firefox",

"moz:firefoxOptions": {

"args": [

],

"prefs": {

}

}

}

06:49:06.480 INFO [ActiveSessionFactory.apply] - Capabilities are: {

"acceptInsecureCerts": true,

"browserName": "firefox",

"moz:firefoxOptions": {

"args": [

],

"prefs": {

}

}

}

06:49:06.486 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)

06:49:06.489 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)

1620715746551 geckodriver INFO Listening on 127.0.0.1:25584

1620715746555 geckodriver INFO Listening on 127.0.0.1:25514

1620715746965 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileKN8q36"

1620715746967 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofileA9BmtM"

[GFX1-]: glxtest: libpci missing

[GFX1-]: glxtest: libEGL missing

[GFX1-]: glxtest: libEGL missing

[GFX1-]: glxtest: libpci missing

[GFX1-]: glxtest: libEGL missing

[GFX1-]: glxtest: libEGL missing

1620715747775 Marionette INFO Marionette enabled

1620715747780 Marionette INFO Marionette enabled

console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))

console.warn: SearchSettings: "get: No settings file exists, new profile?" (new Error("", "(unknown module)"))

1620715752118 Marionette INFO Listening on port 46499

1620715752290 Marionette WARN TLS certificate errors will be ignored for this session

06:49:12.408 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C

1620715752487 Marionette INFO Listening on port 37895

06:49:12.636 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 51017a06-c39c-40e8-8b0c-6e0d79bf0f35 (org.openqa.selenium.firefox.GeckoDriverService)

1620715752650 Marionette WARN TLS certificate errors will be ignored for this session

06:49:12.736 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C

06:49:12.756 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session cb4507f4-8959-4c8c-962a-d0146d8c9722 (org.openqa.selenium.firefox.GeckoDriverService)

1620715752960 Marionette INFO Stopped listening on port 37895

1620715752984 Marionette INFO Stopped listening on port 46499

console.warn: services.settings: main/message-groups sync interrupted by shutdown

console.warn: services.settings: main/cfr-fxa sync interrupted by shutdown

console.warn: SearchService: "_init: abandoning init due to shutting down"

JavaScript error: , line 0: uncaught exception: 2147500036

JavaScript error: , line 0: uncaught exception: 2147500036

JavaScript error: , line 0: uncaught exception: 2147500036

JavaScript error: , line 0: uncaught exception: 2147500036

JavaScript error: , line 0: uncaught exception: 2147500036

JavaScript error: , line 0: uncaught exception: 2147500036

console.warn: services.settings: main/cfr-fxa sync interrupted by shutdown

console.warn: services.settings: main/cfr sync interrupted by shutdown

console.error: "Could not load engine ddg@search.mozilla.org: Error: Attempt to use XPI database when it is not initialized"

console.warn: SearchService: "_init: abandoning init due to shutting down"

JavaScript error: resource://gre/modules/DeferredTask.jsm, line 215: Error: Unable to arm timer, the object has been finalized.

JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 575: uncaught exception: 2147500036

JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 575: uncaught exception: 2147500036

JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 575: uncaught exception: 2147500036

JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 575: uncaught exception: 2147500036

JavaScript error: resource://gre/modules/AsyncShutdown.jsm, line 575: uncaught exception: 2147500036

JavaScript error: resource://gre/modules/CrashManager.jsm, line 833: NotAllowedError: Shutting down and refusing additional I/O tasks

JavaScript error: resource://gre/modules/CrashManager.jsm, line 833: NotAllowedError: Shutting down and refusing additional I/O tasks

ExceptionHandler::GenerateDump cloned child 488

ExceptionHandler::SendContinueSignalToChild sent continue signal to child

ExceptionHandler::WaitForContinueSignal waiting for continue signal...

ExceptionHandler::GenerateDump cloned child 489

ExceptionHandler::SendContinueSignalToChild sent continue signal to child

ExceptionHandler::WaitForContinueSignal waiting for continue signal...

06:50:19.945 INFO [ActiveSessions$1.onStop] - Removing session cb4507f4-8959-4c8c-962a-d0146d8c9722 (org.openqa.selenium.firefox.GeckoDriverService)

06:50:20.353 INFO [ActiveSessions$1.onStop] - Removing session 51017a06-c39c-40e8-8b0c-6e0d79bf0f35 (org.openqa.selenium.firefox.GeckoDriverService)

testproject-agent1&2 container:

Obtained execution configuration for Agent: SQzalOlzw0OzeJXhzhXOMw

2021-05-11 06:48:50.940 [INFO ] i.t.a.Program *** AGENT - START ***

2021-05-11 06:48:51.586 [INFO ] i.t.a.h TestProject Agent 2.3.0 (038c22f72) on Linux

2021-05-11 06:48:51.692 [INFO ] i.t.a.h Running under user agent (/home/agent) of type Unknown with Guest privileges

2021-05-11 06:48:51.693 [INFO ] i.t.a.h Running inside docker 515605a4bed4

2021-05-11 06:48:51.741 [INFO ] i.t.a.h No X11 available - headless mode.

2021-05-11 06:48:51.757 [INFO ] i.t.a.s.IdentityManager No identity file was found - Agent is not registered

2021-05-11 06:48:51.775 [INFO ] i.t.a.h Working folder: /opt/testproject/agent

2021-05-11 06:48:51.775 [INFO ] i.t.a.h Data folder: /var/testproject/agent

2021-05-11 06:48:51.793 [INFO ] i.t.a.h Agent IP addresses: 172.18.0.5

2021-05-11 06:48:53.479 [INFO ] i.t.a.m.f.l No Android SDK found

2021-05-11 06:48:53.514 [INFO ] i.t.a.i.l Waiting a bit for IOS Wrapper to come up...

2021-05-11 06:49:03.588 [INFO ] i.t.a.m.c.a Running in docker - ADB version querying will be skipped.

2021-05-11 06:49:03.589 [INFO ] i.t.a.m.c.a Detected Java [13-ea]

2021-05-11 06:49:03.594 [INFO ] i.t.a.m.c.a Detected DotNet [2.2.8]

2021-05-11 06:49:03.597 [INFO ] i.t.a.m.c.b Searching for installed browsers...

2021-05-11 06:49:03.600 [INFO ] i.t.a.m.c.b Getting external browser version via http://chrome:4444/wd/hub

2021-05-11 06:49:06.242 [ERROR] i.t.a.m.c.b Failed to get external CHROME version via: http://chrome:4444/wd/hub

2021-05-11 06:49:06.258 [INFO ] i.t.a.m.c.b Getting external browser version via http://firefox:4444/wd/hub

2021-05-11 06:49:12.775 [INFO ] i.t.a.m.c.b External FIREFOX version is 88.0

2021-05-11 06:50:20.393 [INFO ] i.t.a.m.c.b Finished detecting installed browsers.

2021-05-11 06:50:20.397 [INFO ] i.t.a.m.c.a Running in docker - drivers detection will be skipped.

2021-05-11 06:50:20.496 [INFO ] i.t.a.m.b Starting gRPC Server on port localhost:43785

2021-05-11 06:50:21.157 [INFO ] i.t.a.m.O Runtime information saved

2021-05-11 06:50:21.157 [INFO ] i.t.a.h Agent initialization is complete.

2021-05-11 06:50:21.160 [INFO ] i.t.a.s.IdentityManager No identity file was found - Agent is not registered

2021-05-11 06:50:21.213 [INFO ] i.t.a.m.f.k Appium server executable not found, assuming mobile components are not installed.

2021-05-11 06:50:21.214 [ERROR] i.t.a.m.x [Alert Message] - Mobile recording session can not be started because Appium failed to start.

Your Antivirus or malware protection software might be blocking it, turn it off and try again.

If this problem persists, please contact TestProject support.

2021-05-11 06:50:21.215 [INFO ] i.t.a.w.b Starting Web Server...

2021-05-11 06:50:21.215 [INFO ] i.t.a.w.b Starting internal web server...

2021-05-11 06:50:21.245 [INFO ] i.t.a.m.K Checking Agent's connectivity with the outside world...

2021-05-11 06:50:23.120 [INFO ] i.t.a.m.K Connection established successfully.

2021-05-11 06:50:23.121 [INFO ] i.t.a.f.c.a.k Direct connection (no proxy) is possible.

2021-05-11 06:50:23.121 [INFO ] i.t.a.f.c.a.k External connectivity is possible, proceeding to Authentication...

2021-05-11 06:50:23.133 [INFO ] i.t.a.f.c.a.a Trying to load Agent remote identity...

2021-05-11 06:50:23.134 [INFO ] i.t.a.s.IdentityManager No identity file was found - Agent is not registered

2021-05-11 06:50:23.135 [INFO ] i.t.a.f.c.a.a Checking if configuration passed via environment variable is present...

2021-05-11 06:50:23.136 [INFO ] i.t.a.f.c.a.a Trying to register with configuration provided...

2021-05-11 06:50:23.154 [INFO ] i.t.a.f.c.a.a Registering agent with configuration

2021-05-11 06:50:23.380 [INFO ] i.t.a.b.b.h Connecting TestProject servers...

2021-05-11 06:50:23.380 [INFO ] i.t.a.m.K Checking Agent's connectivity with the outside world...

2021-05-11 06:50:23.949 [INFO ] i.t.a.m.K Connection established successfully.

2021-05-11 06:50:23.950 [INFO ] i.t.a.b.b.h Registering Agent...

2021-05-11 06:50:23.951 [INFO ] i.t.a.b.b.h Preparing to send registration request to host https://api.testproject.io/

2021-05-11 06:50:24.207 [INFO ] i.t.a.b.b.h Sending registration request to https://api.testproject.io/agents/registration/agents

2021-05-11 06:50:26.662 [INFO ] i.t.a.b.a.d POST https://api.testproject.io/agents/registration/agents - 200 (5fAZw1Gs): No Message

2021-05-11 06:50:26.669 [INFO ] i.t.a.b.b.h Registration request succeeded.

2021-05-11 06:50:26.861 [INFO ] i.t.a.w.b Web server started on http://localhost:8585

2021-05-11 06:50:26.886 [INFO ] i.t.a.m.L Registered successfully

2021-05-11 06:50:26.917 [INFO ] i.t.a.s.IdentityManager Agent identity has been saved

2021-05-11 06:50:26.939 [INFO ] i.t.a.f.c.a.a Agent is registered as [Agent_SQzalOlzw0OzeJXhzhXOMw] (SQzalOlzw0OzeJXhzhXOMw), proceeding to authentication...

2021-05-11 06:50:26.943 [INFO ] i.t.a.f.c.a.a Authenticating with TestProject...

2021-05-11 06:50:26.954 [INFO ] i.t.a.s.c Requesting authenticating token...

2021-05-11 06:50:28.685 [INFO ] i.t.a.s.c Authenticated successfully

2021-05-11 06:50:28.724 [INFO ] i.t.a.m.f.l No Android SDK found

2021-05-11 06:50:28.725 [INFO ] i.t.a.i.l Waiting a bit for IOS Wrapper to come up...

2021-05-11 06:50:38.728 [INFO ] i.t.a.f.c.a.h Starting Signal...

2021-05-11 06:50:39.704 [INFO ] i.t.a.b.c.a Signal connected, awaiting authentication result...

2021-05-11 06:50:39.708 [INFO ] i.t.a.b.c.a Sent empty Session ID

2021-05-11 06:50:40.943 [INFO ] i.t.a.b.c.a Signal authentication finished

2021-05-11 06:50:40.947 [INFO ] i.t.a.b.c.a Connection Session ID: rLU3MvX85y

2021-05-11 06:50:40.947 [INFO ] i.t.a.b.c.a Signal authorized

2021-05-11 06:50:43.188 [INFO ] i.t.a.b.a.d POST https://api.testproject.io/api/v1/agent/certificate - 200 (XdByBDn0): No Message

2021-05-11 06:50:43.236 [INFO ] i.t.a.w.b Added SSL connector

2021-05-11 06:50:43.237 [INFO ] i.t.a.s.IdentityManager Requesting remote identity...

2021-05-11 06:50:43.901 [INFO ] i.t.a.b.a.d GET https://api.testproject.io/api/v1/agent - 200 (HvlYA9LM): No Message

2021-05-11 06:50:43.911 [WARN ] i.t.a.s.IdentityManager Latest version is unknown, Agent might be outdated

2021-05-11 06:50:43.913 [INFO ] i.t.a.s.IdentityManager Agent identity has been saved

2021-05-11 06:50:43.913 [INFO ] i.t.a.f.c.a.d Account plan: Free

2021-05-11 06:50:43.914 [INFO ] i.t.a.h Refreshing & reporting capabilities...

2021-05-11 06:50:43.920 [INFO ] i.t.a.m.c.a Running in docker - ADB version querying will be skipped.

2021-05-11 06:50:43.921 [INFO ] i.t.a.m.c.a Detected Java [13-ea]

2021-05-11 06:50:43.922 [INFO ] i.t.a.m.c.a Detected DotNet [2.2.8]

2021-05-11 06:50:43.922 [INFO ] i.t.a.m.c.a Running in docker - drivers detection will be skipped.

2021-05-11 06:50:45.376 [INFO ] i.t.a.b.a.d POST https://api.testproject.io/api/v1/agent/capabilities - 200 (rkg5KCmY): Capabilities were received

2021-05-11 06:50:45.376 [INFO ] i.t.a.m.f.l No Android SDK found

2021-05-11 06:50:45.377 [INFO ] i.t.a.i.l Waiting a bit for IOS Wrapper to come up...

2021-05-11 06:50:55.381 [INFO ] i.t.a.b.b.c Retrieving list of provisioned iOS devices...

2021-05-11 06:50:57.464 [ERROR] i.t.a.b.a.d GET https://api.testproject.io/api/v1/devices/provisioned - 404 (null): No Message

2021-05-11 06:50:57.465 [ERROR] i.t.a.b.b.c Failed to retrieve list of provisioned devices.

2021-05-11 06:50:57.467 [INFO ] i.t.a.b.b.c Reporting state: Idle

2021-05-11 06:51:09.077 [INFO ] i.t.a.m.A Reported Agent state and got response - [Agent Version: 2.3.0]

2021-05-11 06:51:09.086 [INFO ] i.t.a.m.d.p Report uploading manager started.

In your docker compose yml file, change the chrome/firefox containers with this:

  chrome:
    image: selenium/standalone-chrome
    shm_size: '1gb'
  firefox:
    image: selenium/standalone-firefox
    shm_size: '1gb'

(I have added shm_size: ‘1gb’ in each one)

Let me know if that helped.

Also, I tried this and I am getting this error:

org.openqa.selenium.WebDriverException: Failed to create an instance of io.testproject.sdk.drivers.web.FirefoxDriver

Still seeing same error!

I see.
Please send an email to support@testproject.io and we will have a zoom call to see what the issue is.

1 Like

Hello @shivam
Both of the issues we saw are fixed in Java OpenSDK version 1.2.0

Thanks Ran, for all your help.
This sounds great.

Hi,

Thanks for all the help till now.
Could you guys please help me to setup my project on AWS for cloud execution? I am not sure how can I do this configuration.

Thanks

Hey @ran.tzur ,

I tried setting up my project on AWS ec2 instance for execution. I used the docker-compose file to create containers on EC2 linux AMI and I was able to successfully start the testproject agent on it. When I tried execution my script on AWS, it worked perfectly for 8585 port but for port 8888, I am getting an error:

[main] INFO io.testproject.sdk.internal.rest.AgentClient - Initializing new session...
[main] INFO io.testproject.sdk.internal.rest.AgentClient - Session [8006fffdaf57d6ed368bb23d5608509f] initialized
[main] INFO io.testproject.sdk.internal.rest.AgentClient - Report URL: http://18.116.15.185:8585/api/report/20210525-095623.html
[main] ERROR io.testproject.sdk.internal.tcp.SocketManager - Failed connecting to Agent socket at 18.116.15.185:8787
java.net.ConnectException: Connection refused: connect
	at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)
	at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.base/java.net.Socket.connect(Socket.java:608)
	at io.testproject.sdk.internal.tcp.SocketManager.openSocket(SocketManager.java:120)
	at io.testproject.sdk.internal.rest.AgentClient.startSession(AgentClient.java:758)
	at io.testproject.sdk.internal.rest.AgentClient.<init>(AgentClient.java:273)
	at io.testproject.sdk.internal.rest.AgentClient.getClient(AgentClient.java:543)
	at io.testproject.sdk.drivers.web.ChromeDriver.<init>(ChromeDriver.java:757)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at io.testproject.sdk.DriverBuilder.build(DriverBuilder.java:235)
	at Steps.WebConnector.setUpDriver(WebConnector.java:82)
	at Steps.WebConnector.iOpenWebBrowser(WebConnector.java:108)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
	at io.cucumber.java.Invoker.invoke(Invoker.java:24)
	at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
	at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
	at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
	at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
	at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
	at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
	at io.cucumber.core.runner.TestStep.run(TestStep.java:64)
	at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
	at io.cucumber.core.runner.TestCase.run(TestCase.java:104)
	at io.cucumber.core.runner.Runner.runPickle(Runner.java:73)
	at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
	at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
	at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
	at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
	at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
	at io.cucumber.core.cli.Main.run(Main.java:92)
	at io.cucumber.core.cli.Main.main(Main.java:34)

Step failed
org.openqa.selenium.WebDriverException: Failed to create an instance of io.testproject.sdk.drivers.web.ChromeDriver
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'SHIVAM', ip: '172.29.32.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.11'
Driver info: driver.version: unknown
	at io.testproject.sdk.DriverBuilder.build(DriverBuilder.java:246)
	at Steps.WebConnector.setUpDriver(WebConnector.java:82)
	at Steps.WebConnector.iOpenWebBrowser(WebConnector.java:108)
	at ✽.I open web browser on port 8888(file:///B:/testproject-poc/src/test/java/Features/Canvas.feature:4)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at io.testproject.sdk.DriverBuilder.build(DriverBuilder.java:235)
	at Steps.WebConnector.setUpDriver(WebConnector.java:82)
	at Steps.WebConnector.iOpenWebBrowser(WebConnector.java:108)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
	at io.cucumber.java.Invoker.invoke(Invoker.java:24)
	at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
	at io.cucumber.java.JavaStepDefinition.execute(JavaStepDefinition.java:29)
	at io.cucumber.core.runner.CoreStepDefinition.execute(CoreStepDefinition.java:66)
	at io.cucumber.core.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:63)
	at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
	at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
	at io.cucumber.core.runner.TestStep.run(TestStep.java:64)
	at io.cucumber.core.runner.PickleStepTestStep.run(PickleStepTestStep.java:51)
	at io.cucumber.core.runner.TestCase.run(TestCase.java:104)
	at io.cucumber.core.runner.Runner.runPickle(Runner.java:73)
	at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110)
	at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:117)
	at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
	at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
	at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at io.cucumber.core.runtime.Runtime.run(Runtime.java:87)
	at io.cucumber.core.cli.Main.run(Main.java:92)
	at io.cucumber.core.cli.Main.main(Main.java:34)
Caused by: io.testproject.sdk.internal.exceptions.AgentConnectException: Failed connecting to Agent socket
	at io.testproject.sdk.internal.tcp.SocketManager.openSocket(SocketManager.java:155)
	at io.testproject.sdk.internal.rest.AgentClient.startSession(AgentClient.java:758)
	at io.testproject.sdk.internal.rest.AgentClient.<init>(AgentClient.java:273)
	at io.testproject.sdk.internal.rest.AgentClient.getClient(AgentClient.java:543)
	at io.testproject.sdk.drivers.web.ChromeDriver.<init>(ChromeDriver.java:757)
	... 44 more
Caused by: java.net.ConnectException: Connection refused: connect
	at java.base/java.net.PlainSocketImpl.waitForConnect(Native Method)
	at java.base/java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:107)
	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.base/java.net.Socket.connect(Socket.java:608)
	at io.testproject.sdk.internal.tcp.SocketManager.openSocket(SocketManager.java:120)
	... 48 more

Hi,

Use the below java code -

public class stepDefinition {

WebDriver dr;

@Given ( "^navigate to gmail page$" )

public void navigate(){

dr= new FirefoxDriver();

dr.get( "http://www.gmail.com" );

}

@When ( "^user logged in using username as \"(.*)\" and password as \"(.*)\"$" )

public void login(String username,String password){

dr.findElement(By.xpath( "//*[@id='Email']" )).sendKeys(username);

dr.findElement(By.xpath( "//*[@id='Passwd']" )).sendKeys(password);

dr.findElement(By.xpath( "//*[@id='signIn']" )).click();

dr.manage().timeouts().implicitlyWait( 20 , TimeUnit.SECONDS);

}

@Then ( "^home page should be displayed$" )

public void verifySuccessful(){

String expectedText= "Gmail" ;

String actualText= dr.findElement(By.xpath( "//*[@id='gbq1']/div/a/span" )).getText();

Assert.assertTrue( "Login not successful" ,expectedText.equals(actualText));

}

}