Karate UI : data driven testing not working properly when used driver.quit() - karate

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

Related

Karate :On teamcity facing issue of http connection refused error for localhost

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/

[karate]: Karate UI Automation: Unable to launch the browser

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

Getting "HttpHostConnectException" connection refused while running Karate UI Testcases through jenkins

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

Call failed after 702 milliseconds

I see the error below when I run my first script.
com.intuit.karate.exception.KarateException: http call failed after 702 milliseconds for URL: https://qa.myorg.intVersion.
Here is my feature file.
Feature: Test feature
Scenario: Verify my service is up and running
Given url 'https://qa.myorg.int\Version'
When method get
Then status 200
Here is my Java file:
package examples
import org.junit.runner.RunWith
import com.intuit.karate.junit4.Karate
#RunWith(Karate.class)
public class jenkinsTest {
}
I have waited manually for a long time in debug mode. Still, I see the error below and no HTML reports are loaded into the target folder. (I see ONLY Karate.log under target folder.)
11:36:23.751 [main] ERROR com.intuit.karate - javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target, http call failed after 271489 milliseconds for URL: https://qa.myorg.int/Version
How can I solve it?
Refer to the configure documentation for SSL. Try this:
Feature: Test feature
Background:
* configure ssl = true
Scenario: Verify my service is up and running
Given url 'https://qa.myorg.int/Version'
When method get
Then status 200

JDBC client to Hive - No data or no sasl data in the stream Exception

We have a Kerberised cluster and I'm trying to run a Java action in Oozie where I make a JDBC connection to Hive. This JDBC connections works fine on the Sandbox without Kerberos.
The connection string is as simple as the following, where I'm providing username and password in it:
Connection con = DriverManager.getConnection("jdbc:hive2://W12345:10000/control;principal=hive/W12345.companynet.net#COMPANYNET.NET","user123","passw123");
The Oozie action (strangely) completes succesfully, and the Java action log does not present any error:
1742 [main] INFO org.apache.hive.jdbc.Utils - Supplied authorities: W12345:10000
1742 [main] INFO org.apache.hive.jdbc.Utils - Resolved authority: W12345:10000
1766 [main] INFO org.apache.hive.jdbc.HiveConnection - Will try to open client transport with JDBC Uri: jdbc:hive2://W12345:10000/control;principal=hive/W12345.companynet.net#COMPANYNET.NET
<<< Invocation of Main class completed <<<
Oozie Launcher ends
1785 [main] INFO org.apache.hadoop.mapred.Task - Task:attempt_1464245290012_0129_m_000000_0 is done. And is in the process of committing
1847 [main] INFO org.apache.hadoop.mapred.Task - Task attempt_1464245290012_0129_m_000000_0 is allowed to commit now
1854 [main] INFO org.apache.hadoop.mapreduce.lib.output.FileOutputCommitter - Saved output of task 'attempt_1464245290012_0129_m_000000_0' to hdfs://danskehadoop/user/user123/oozie-oozi/0000013-160527101253015-oozie-oozi-W/JavaAction--java/output/_temporary/1/task_1464245290012_0129_m_000000
1909 [main] INFO org.apache.hadoop.mapred.Task - Task 'attempt_1464245290012_0129_m_000000_0' done.
But in reality the Java main does not complete correctly the execution (and does not execute the needed queries) because the JDBC connection fails with an exception that I can see only in the Hive log:
ERROR [HiveServer2-Handler-Pool: Thread-78363]: server.TThreadPoolServer (TThreadPoolServer.java:run(296)) - Error occurred during processing of message.
java.lang.RuntimeException: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:219)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory$1.run(HadoopThriftAuthBridge.java:739)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory$1.run(HadoopThriftAuthBridge.java:736)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1637)
at org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory.getTransport(HadoopThriftAuthBridge.java:736)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:268)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.thrift.transport.TSaslTransportException: No data or no sasl data in the stream
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:328)
at org.apache.thrift.transport.TSaslServerTransport.open(TSaslServerTransport.java:41)
at org.apache.thrift.transport.TSaslServerTransport$Factory.getTransport(TSaslServerTransport.java:216)
... 10 more
I'm actually connected to the cluster, and already done further kinit on my username.
Does anybody know what could the cause of this exception be?
Thanks in advance for the help!
Antonio
This happened to me on MapR hadoop distribution platform.
In my case it was Keepalived checking Hive port every 5 seconds and producing such error. I simply used "nc" command to check if Hive port is in use and did not use any authentication method. Later I switched to "maprcli" command which uses SASL authentication and the error was gone.