1

In the below code i would like to use chromedriver in Karate

but do not want to give the hardcoded path C:\Software\chromedriver_win32\chromedriver.exe

Reason :- Other team members might not have the chromedriver at the same path.

Feature: Check to open both browser

 Scenario: open chrome with chromeDriver
* configure driver = {type:'chromedriver' , executable:'C:\\Software\\chromedriver_win32\\chromedriver.exe'}
* driver 'https://www.google.com'

Any ways of handling this automatically? so that it's downloaded via maven and Karate picks it up.

Instead of we downloading it(chromedriver/geckodriver) manually and putting in a relative folder(in project) or system folder

I have read the documentation which says it search in system PATH in windows or the one we give.

Anything which i might be missing please correct me.

Gaurav Khurana
  • 3,423
  • 2
  • 29
  • 38

1 Answers1

1

Most teams use the PATH default because it is easier to customize per machine.

But if you are expecting Karate to automatically download a driver via Maven or something like that, sorry that's not supported nor is it ever planned.

Maybe you should look at WebDriverManager - just add it to your dependencies and use it, should be simple.

Also you should spend some time understanding Karate's config system: https://github.com/intuit/karate#configuration

So assuming that you have the following karate-config.js:

function fn() {
  return { executable: 'C:/some/dir/chromedriver.exe' }
}

Now in any feature file the variable executable will be set and available to use.

* configure driver = { type:'chromedriver', executable: '#(executable)' }

Take a look at this answer also: https://stackoverflow.com/a/60581024/143475

And you can study the project that Karate uses for CI

Also see: https://stackoverflow.com/a/68821168/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thank you @Peter Thomas. 1) I have used Webdrivermanager , can it be used in karate somehow ? i dont want karate to download but if it can read the project folder 2) whether i put C:/some/dir/chromedriver in config file.. its one of the same thing.. the path remain hardcoded 3) My concern is when it will run on a build agent via CI where it will find chromedrive as it will run on a remote server. (i am trying to undertsnading your last point of CI) how it works.. Is there any detailed explanation for that point ? – Gaurav Khurana Mar 23 '21 at 11:55
  • 1
    @Gauravkhurana sorry, no detailed explanation of CI, you'll have to go through the documentation and then the code to understand. and as I said integrating webdrivermanager is your responsibility, I don't have an example - but if you have used it, you should have no trouble writing a JUnit `@BeforeClass` hook to ensure it is in the right directory before any of your karate tests run. And then you can pass it to karate config so you don't have to hard-code :) – Peter Thomas Mar 23 '21 at 12:13