I am getting below error while executing testcases through jenkins. jenkin is running on linux slave.
[ERROR] 2020-09-10 03:07:19.692 [ForkJoinPool-1-worker-1] c.i.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
[ERROR] 2020-09-10 03:07:19.692 [ForkJoinPool-1-worker-1] c.i.karate - http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
I have written below code for karate UI Automation to launch the chrome browser
Feature: Driver initialization
Background:
* def loginloc = read('classpath:pageobjects/LoginPage.json')
Scenario: Driver initialization
* configure driver = {type: 'chrome', showDriverLog: false}
* driver environment.ScriptEditor.baseurl
* driver.maximize()
* retry().waitFor(loginloc.headingtext)
* driver.waitUntil("document.readyState == 'complete'")
Chrome may not be on the Jenkins worker node or it typically will not support a UI test. This is what the Docker container is for. Read the docs: https://github.com/intuit/karate/tree/master/karate-core#dockertarget
Related
I have karate test suite to execute on teamcity.It is supposed to connect to https://localhost:8086/ but it fails intermittently with error : connecting refused after xxx miliseconds to http://localhost:8086/
I am working on automating a API which is hosted in China server and when I send a request it throws me timeout exception ( org.apache.http.conn.HttpHostConnectException).
My feature file:
Background:
* url 'http://myurl'
* configure connectTimeout = 500000
Scenario: Get Client details
Given path '/clients'
And header Authorization = 'sdssSSLwWDSD'
When method get
Then match response.client_id == 'TestId'
Error details:
11:22:30.347 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://myurl.com][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10]
11:22:30.365 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://myurl.com][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 10]
11:22:30.365 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://myurl.com
11:22:30.384 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to myurl.com/54.223.191.33:443
11:22:30.384 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to myurl.com/54.223.191.33:443 with timeout 500000
11:22:51.407 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connect to myurl.com/54.223.191.33:443 timed out. Connection will be retried using another IP address
11:22:51.407 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to myurl.com/52.80.167.86:443
11:22:51.408 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to myurl.com/52.80.167.86:443 with timeout 500000
11:23:12.438 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
11:23:12.439 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
11:23:12.440 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://myurl.com:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10]
11:23:12.440 [main] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to myurl.com [myurl.com/54.223.191.33, myurl.com/52.80.167.86] failed: Connection timed out: connect, http call failed after 42094 milliseconds for URL: https://myurl.com/tnc/v1/tnc/all
11:23:12.441 [main] ERROR com.intuit.karate - http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to myurl.com:443 [myurl.com/54.223.191.33, myurl.com/52.80.167.86] failed: Connection timed out: connect
11:23:12.601 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager is shutting down
11:23:12.601 [Finalizer] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager shut down
HTML report: (paste into browser to view) | Karate version: 0.9.4
What I have tried yet:
I tried to configure timeout to max as below:
* configure connectTimeout = 500000
It didn't work.
However, the same request when tried from Postman, works fine and I get response within 2000 ms.
Not sure where I am wrong.
Most likely you have a corporate HTTP proxy.
Refer: https://github.com/intuit/karate#configure
* configure proxy = 'http://my.proxy.host:8080'
The compiler is looking target folder for the chrome.exe file. In which it is looking for some chrome_1639142447236 file. Actually it is available at C:\Program Files (x86)\Google\Chrome\Application this location.
Below error message I'm getting:
18:51:39.096 [ForkJoinPool-1-worker-3] ERROR com.intuit.karate -
org.apache.http.conn.HttpHostConnectException: Connect to
localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]
failed: Connection refused: no further information, http call failed
after 4022 milliseconds for URL: http://localhost:9222 18:51:39.098
[ForkJoinPool-1-worker-3] ERROR com.intuit.karate - http request
failed:
Below is the feature level error message:
failed features: src.test.java.examples.users.Sample: Sample.feature:9
driver config / start failed: org.apache.http.conn.HttpHostConnectException: Connect to
localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]
failed: Connection refused: no further information, options:
{type=chrome, target=null}
If you know where the chrome executable is, please follow the instructions to customize it in your Karate tests: https://github.com/karatelabs/karate/tree/master/karate-core#configure-driver
* configure driver = { type: 'chrome', executable: 'chrome' }
Also read this answer for even more details: https://stackoverflow.com/a/66762430/143475
We are exploring Karate UI(already using Karate for API testing). For exploring purpose we are using https://www.delta.com/ and its working fine. However have observed following behavior while implementing data driven test
Following is the simple feature file for search destination
Feature: Karate UI POC
Background: To set the browser driver
* configure driver = { type: 'chromedriver', executable: "path to exe"}
* def data=
"""
{
fromDes: '#(from)'
}
"""
Scenario: Launch the application search for the valid flights
Given driver 'https://www.delta.com/'
* driver.maximize()
* waitUntil("document.readyState == 'complete'")
* waitForEnabled('#fromAirportName').click()
* waitForEnabled('#search_input')
* clear('#search_input')
* input('#search_input',data.fromDes)
* driver.quit()
From data.feature file I am making a call to above feature file as follows
* table destinations
| from |
| 'NEW YORK' |
| 'BOSTON' |
* call read('delta.feature') destinations
On executing the test I am getting following error
17:26:55.443 [main] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect, http call failed after 2054 milliseconds for URL: http://localhost:9515/session/6fa82b59df1c1c845974c2f52d481d11/url
17:26:55.445 [main] ERROR com.intuit.karate - http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
17:26:55.445 [main] WARN c.i.k.d.chromedriver_1592481370453 - session delete failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: connect
17:26:55.445 [main] DEBUG com.intuit.karate.shell.Command - closing command: chromedriver_1592481370453
1) However if I remove statement driver.quit() test is working fine.
2) Is it a right approach for data driven testing in Karat UI, as we are using it quit well in Karate API
You don't need to use quit() at all, Karate will do it automatically.
Can you also try with version 0.9.6.RC3
If you still see an issue, follow this process and we will make sure it is fixed: https://github.com/intuit/karate/tree/develop/examples/ui-test
I am using Mac and installed Microsoft Edge but getting this error when I try to run the script. It works fine for Chrome, Firefox and Safari.
* configure driver = { type: mswebdriver, showDriverLog: true}
23:26:42.311 request:
1 > POST http://localhost:17556/session
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 55
1 > Content-Type: application/json; charset=UTF-8
1 > Host: localhost:17556
1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_242)
{"capabilities":{"alwaysMatch":{"browserName":"edge"}}}
23:26:42.321 org.apache.http.conn.HttpHostConnectException: Connect to localhost:17556 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused), http call failed after 10 milliseconds for URL: http://localhost:17556/session
23:26:42.322 http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:17556 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
23:26:42.323 driver config / start failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:17556 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused), options: {type=mswebdriver, showDriverLog=true, target=null}
shopifysg.feature:10 - driver config / start failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:17556 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused), options: {type=mswebdriver, showDriverLog=true, target=null}
Update the Karate-core version greater than 1.1.0 it works
This isn't there on 0.9.5 but it is in the develop branch. You should use msedgedriver, refer: https://github.com/intuit/karate/tree/develop/karate-core#driver-types
I think it is there in 0.9.6.RC1 - so can you try that first. If not, please help us by following the developer guide, so that we can release this sooner: https://github.com/intuit/karate/wiki/Developer-Guide