'While running the Karate test for UI actions, on Jenkins using docker image , I am not able to run the same

While trying to running the Karate test for UI actions, using docker image i.e "https://hub.docker.com/r/ptrthomas/karate-chrome" , I am not able to run the same.

I have used below commands as per the document "[https://github.com/karatelabs/karate/wiki/Docker"][1]

docker run --name karate --rm -p 5901:5900 --cap-add=SYS_ADMIN -v "$PWD":/src ptrthomas/karate-chrome

and once it is running I run the below Command

docker exec -it -w /src karate mvn clean test -DargLine='-Dkarate.env=docker'

Feature file as below

Feature: Verify that in case of valid credentials, user is able to login in  Window as well as session token is generated successfully.

  Background: 
    * configure driver = { type: 'chrome'}

  Scenario: Verify that in case of valid credentials, user is able to login in Fusion Auth Window as well as session token is generated successfully.
    Given driver 'http://globaldeveloperexperience.ilb.dev.pdx13.clover.network/globaldeveloperexperience/login'
    And waitFor('input[id=loginId]')
    And input('input[id=loginId]', '[email protected]')
    And input('input[id=password]', 'Test0101@')
    When click('.blue')
    Then waitFor('pre')
    And json response = text('pre')
    And match response.sessionToken == '#notnull'

Runner class as below:

package com.gde.automation.gdeTestRunners;

import com.intuit.karate.junit5.Karate;
import com.intuit.karate.junit5.Karate.Test;

public class gdeTestCaseRunner {

    @Test
    public Karate runTestUsingClassPath() {
        return Karate.run("classpath:com/gde/automation/gdeTestCases/LoginFlow/validateSessionToken.feature");
    }
}

Karate-config.js file as below

function fn() {
  var env = karate.env; // get system property 'karate.env'
  karate.log('karate.env system property was:', env);
  if (!env) {
    env = 'staging';
  }
  var config = {
    env: env,
    myVarName: 'someValue'
  }
  if (env == 'dev') {
    // customize
    // e.g. config.foo = 'bar';
  } else if (env == 'e2e') {
    // customize
  }
  return config;
}

I am getting the below error:

 Still I am getting the below error:
T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.gde.automation.ParallelBuilderWithCucumberReport
09:19:45.299 [main] INFO  com.intuit.karate.Runner - using system property 'karate.env': staging
09:19:46.281 [main] DEBUG com.intuit.karate.Suite - [config] classpath:karate-config.js
09:19:49.693 [pool-1-thread-1] INFO  com.intuit.karate - karate.env system property was: staging 
09:19:49.986 [pool-1-thread-1] DEBUG com.intuit.karate.shell.Command - found / verified free local port: 37353
09:19:49.987 [pool-1-thread-1] WARN  c.intuit.karate.driver.DriverOptions - preferred port 9222 not available, will use: 37353
09:19:49.992 [chrome_1650532789980] DEBUG c.i.k.driver.chrome_1650532789980 - command: [/usr/bin/google-chrome, --remote-debugging-port=37353, --no-first-run, --user-data-dir=/src/target/chrome_1650532789980, --disable-popup-blocking], working dir: target/chrome_1650532789980
09:19:49.994 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #0 for port to be ready - localhost:37353
09:19:50.032 [chrome_1650532789980-out] DEBUG c.i.k.driver.chrome_1650532789980 - [898:898:0421/091950.031354:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
09:19:50.036 [chrome_1650532789980] WARN  com.intuit.karate.shell.Command - exit code was non-zero: 1 - [/usr/bin/google-chrome, --remote-debugging-port=37353, --no-first-run, --user-data-dir=/src/target/chrome_1650532789980, --disable-popup-blocking] working dir: target/chrome_1650532789980
09:19:50.255 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #1 for port to be ready - localhost:37353
09:19:50.508 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #2 for port to be ready - localhost:37353
09:19:50.760 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #3 for port to be ready - localhost:37353
09:19:51.015 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #4 for port to be ready - localhost:37353
09:19:51.267 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #5 for port to be ready - localhost:37353
09:19:51.519 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #6 for port to be ready - localhost:37353
09:19:51.773 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #7 for port to be ready - localhost:37353
09:19:52.025 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #8 for port to be ready - localhost:37353
09:19:52.278 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #9 for port to be ready - localhost:37353
09:19:52.530 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #10 for port to be ready - localhost:37353
09:19:52.782 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #11 for port to be ready - localhost:37353
09:19:53.035 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #12 for port to be ready - localhost:37353
09:19:53.287 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #13 for port to be ready - localhost:37353
09:19:53.540 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #14 for port to be ready - localhost:37353
09:19:53.792 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #15 for port to be ready - localhost:37353
09:19:54.044 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #16 for port to be ready - localhost:37353
09:19:54.296 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #17 for port to be ready - localhost:37353
09:19:54.549 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #18 for port to be ready - localhost:37353
09:19:54.802 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #19 for port to be ready - localhost:37353
09:19:55.054 [pool-1-thread-1] DEBUG c.i.k.driver.chrome_1650532789980 - poll attempt #20 for port to be ready - localhost:37353
09:19:55.826 [pool-1-thread-1] DEBUG com.intuit.karate - request:
1 > GET http://localhost:37353/json
1 > Host: localhost:37353
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_322)
1 > Accept-Encoding: gzip,deflate


09:19:55.883 [pool-1-thread-1] ERROR com.intuit.karate - karate.org.apache.http.conn.HttpHostConnectException: Connect to localhost:37353 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 528 milliseconds for url: http://localhost:37353/json
09:19:57.885 [pool-1-thread-1] DEBUG com.intuit.karate.shell.Command - attempt #1 waiting for http to be ready at: http://localhost:37353/json
09:19:57.889 [pool-1-thread-1] DEBUG com.intuit.karate - request:
2 > GET http://localhost:37353/json
2 > Host: localhost:37353
2 > Connection: Keep-Alive
2 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_322)
2 > Accept-Encoding: gzip,deflate


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source