2

When I run the test remotely in chrome browser, I was faced with the error [type: STRING, value: Host header is specified and is not an IP address or localhost.] It is an issue https://github.com/web-iq/chrome-remote-debug/issues/1

To overcome it I should set the header = {host: 'localhost'}. The IP address is impossible to use in my case.

My driver configuration:

   if (driver == 'docker') {
    var driverConfig = {
        type: 'chrome',
        showDriverLog: true,
        start: false,
        host: 'karate-chrome.test.svcj',
        port: 9222
    };
    karate.configure('driver', driverConfig);
}

Please, provide the solution for adding "Host" header into addOptions.

Svitlana
  • 83
  • 2

1 Answers1

1

It is not clear for which request we need to have this host header and we would like some help replicating this and maybe you can submit a pull request with help from your team.

If you use the Docker container for Karate, it will start "socat" along with Chrome and do port forwarding so you don't run into this problem. Here is an excerpt from the Docker file:

[program:socat]
command=/usr/bin/socat tcp-listen:9222,fork tcp:localhost:9223

So maybe you can add something like this into your environment.

halfer
  • 19,824
  • 17
  • 99
  • 186
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • 1
    Let me add some details here. We're using your image ptrthomas/karate-chrome deployed to OpenShift and started correctly with KARATE_SOCAT_START=true env variable. But we were unable to specify inside driver an OpenShift service associated with karate-chrome pod. It works only with IP address and it looks like a bug inside chrome with the host differs from localhost. – Eluvium Dec 20 '19 at 14:28
  • @Eluvium ok. can you also experiment with https://github.com/intuit/karate/wiki/Distributed-Testing - this has the advantage that karate always runs *within* the Docker container. this does need some more testing, but with your help maybe we can get there :) meanwhile if you can give us a way to replicate your original question / problem that will help: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue – Peter Thomas Dec 20 '19 at 14:45
  • Thank you for your recommendations. In our case it is impossible to use https://github.com/intuit/karate/wiki/Distributed-Testing. According to our project requirements, the tests are run in already run docker container. Specifying either localhost or ip address is a limitation of devtools chrome https://github.com/chromedp/chromedp/issues/505. It is the reason why we need header "localhost " for run our tests in docker container. – Svitlana Dec 24 '19 at 08:59
  • @Svitlana so if you help us understand where in the code we need to put this header we can do it. because right now it is not clear at all. and do try to get us a way to replicate as per the link above. maybe you can ask someone in your organization to help. – Peter Thomas Dec 24 '19 at 09:06
  • 1
    @Svitlana I know it's been over a year but with version 1.1.0 of Karate you will be able to overcome this by setting the property `remoteHost` in the configuration of your driver. E.g. if you use the docker one: `{ docker: 'ptrthomas/karate-chrome', showDriverLog: true, remoteHost: true};` See here for more details: https://github.com/intuit/karate/pull/1603 – jramos May 23 '21 at 15:02