1

We have done UI automation using karate framework. But I am facing challenges while trying to run the tests using gitlab pipeline.

I am using gradle build tool and added a simple step in the gitlab-ci.yaml, but the build fails every time. Here is what I tried: Added this in feature file: * configure driver = { type: 'chrome', headless: true } Got the error:

  18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://localhost:9222
  18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to localhost/127.0.0.1:9222
  18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-8: Shutdown connection
  18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
  18:10:39.057 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 8][route: {}->http://localhost:9222][total available: 0; route allocated: 0 of 5; total allocated: 0 of 10]
  18:10:39.057 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 1 milliseconds for URL: http://localhost:9222

Also, tried by adding chromedriver: * configure driver = { type: 'chromedriver', port: 9515, executable: 'chromedriver' }. Got this error:

   18:19:01.541 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://localhost:9515][total available: 0; route allocated: 0 of 5; total allocated: 0 of 10]
    18:19:01.542 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 19 milliseconds for URL: http://localhost:9515/session
    18:19:01.542 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - http request failed: 
    org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1] failed: Connection refused (Connection refused)

I want to execute the tests on a particular environment when pipeline runs but nothing is working as of now.

Jill
  • 47
  • 8

2 Answers2

1

We can add the code to install chrome and chrome driver in before_script in .gitlab-ci.yml to solve the issue mentioned.

before_script:
  - apt-get update && apt-get install -y --no-install-recommends google-chrome-stable
  - wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
  - unzip chromedriver_linux64.zip
  - mv chromedriver /usr/bin/chromedriver
  - chown root:root /usr/bin/chromedriver
  - chmod +x /usr/bin/chromedriver

Jill
  • 47
  • 8
0

UI and CI is not easy, we have documented how to use the karate-chrome container: https://github.com/intuit/karate/tree/master/karate-core#karate-chrome

And others have had success with SaaS providers: https://stackoverflow.com/a/60992292/143475

If you are trying another route, you may need to do some research / digging. And please contribute your findings back to the community.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I was able to resolve this issue by installing the chrome on the gitlab CI runner. Earlier I was directly trying to configure chrome driver but looks like chrome needs to be installed before we can use: `* configure driver = { type: 'chromedriver', port: 9515, executable: 'chromedriver' }` – Jill Jan 15 '21 at 16:19