3

I used to get frequent chrome driver error in karate UI tests. I have been using karate tests in VS code for the past 5 months. Now, I used to get driver config / start failed: chrome server returned empty list from http://localhost:[port] frequently. Sometimes, I need to run 20 times to run the same test to succeed. All other runs throws either "driver config / start failed: chrome server returned empty list" / "ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed"

I have installed chrome multiple times but I get the same error. Also I have re-imaged my laptop due this issue and through something went wrong. Even now I used to get the above errors often.

I have installed Chrome 64 bit in windows laptop, it get installed in "C:\Program Files\Google\Chrome\Application\chrome.exe" but karate standalone will always check the Chrome path "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" in runtime which doesn't exists.

Note: I have set the chrome.exe installed path in my system environment PATH but karate not considering the path variable. Please advise me on this.

So I have modified the driver config as given below:-

* configure driver = { type: 'chrome', headless: true  } 

[To]

* configure driver = { type: 'chrome', executable: 'C:/Program Files/Google/Chrome/Application/chrome.exe', headless: true  } 

Karate version: 0.9.6.RC3 OS : Windows 10 Home

JDK Version

openjdk version "11" 2018-09-25 OpenJDK Runtime Environment 18.9 (build 11+28) OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

Chrome Driver config

  • configure driver = { type: 'chrome', executable: 'C:/Program Files/Google/Chrome/Application/chrome.exe', headless: true }

Chrome Driver Errors

testui.feature:8 - driver config / start failed: chrome server returned empty list from http://localhost:54311, options: {type=chrome, executable=C:/Program Files/Google/Chrome/Application/chrome.exe, headless=true, target=null}

ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed: [1.1:33] test_page.feature:9 - driver config / start failed: chrome server returned empty list from http://localhost:55676, options: {type=chrome, executable=C:/Program Files/Google/Chrome/Application/chrome.exe, headless=true, target=null}

ERROR com.intuit.karate - evaluation of 'karate-config.js' failed: javascript function call failed: [1.1:33] test_page.feature:11 - evaluation (js) failed: input('#username', 'admin'), failed to get reply for: [id: 23, method: Input.dispatchKeyEvent, params: {modifier=0, type=keyDown, text=k}]

Please guide me how to resolve this issue.

Thanks, Chandra

4 Answers4

1

I was same error. Actually its finding chrome.exe in different location where actually its not located.

In default it's looking at "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"

but actual path was 'C:/Users/ues/AppData/Local/Google/Chrome/Application/chrome.exe'

So check your chrome.exe path.

Hope it's helpful.

Majedur
  • 3,074
  • 1
  • 30
  • 43
1

I have solved my problem by defining in the config file as; "karate.configure('driver', { type: 'chrome', port: 9222, executable: 'C://Program Files//Google//Chrome//Application//chrome.exe' });"

maybe assigning a port help me to solve the issue but one thing to consider here is that u need to use forward slashes in the executable command.

mguzelel
  • 11
  • 1
1

This was the top hit for a recent search I had for this symptom. In my case it turned out the be realted to the new Chorme headless mode. Adding my fix here in case it can be helpful to others:

In my case, explicitly using addOptions to specify headless new fixed this symptom for me:

* configure driver = { type: 'chrome', headless: true, addOptions: [ '--headless=new' ] }

More context:

AndrewJC
  • 1,318
  • 12
  • 11
0

No one else has reported this, so you'll need to figure this out maybe with the help of someone who can troubleshoot your machine. Maybe there are some permission restrictions. Maybe your old processes are still running, so make sure you go to your task manager and kill them etc, this is quite common on Windows.

And please upgrade to 1.0 before trying anything else, because that may help: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

Otherwise we will need your help to maybe debug and suggest changes to the framework. Ideally you should contribute code to Karate, and remember - it is an open source project. If you are able to replicate your problems, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue - but I'm not sure that is possible with the kinds of issues you are describing.

If none of the above options work, you may need to consider switching to some other framework.

EDIT: most teams run on CI + Docker which is much more stable: https://stackoverflow.com/a/62325328/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 2
    I noticed that on headless chrome often the `/json` endpoint returns an empty array until a page is opened. For example in my testing it returns [] until I run `curl http://localhost:9222/json/new\?url\=www.google.com`, after that it is no longer an empty list. Maybe the logic in karate needs to be reworked here? I personally get this error every time I open the browser in karate and none of the suggestions here have worked. – Owen Kuhn Feb 21 '23 at 22:24
  • 1
    Also slightly unrelated but it looks like chrome needs the `--disable-gpu` option when using `--headless` on windows as per this page: https://developer.chrome.com/blog/headless-chrome/#starting-headless-cli – Owen Kuhn Feb 21 '23 at 22:27