1

While executing the UI test in karate a chrome file got created in the target folder which consumes a lot of space as I am working on the virtual machine that reflects into the cost of the machine So anyhow is it possible to stop the creation of that file as I have to manually delete those files?

Ninja
  • 433
  • 3
  • 10

2 Answers2

4

Based on your feedback we've just added a userDataDir option to the driver config.

Please see commit for details:

https://github.com/intuit/karate/commit/0af1ba16f66ef8d1f700edb3bf1f4ba55c865f00

So you can do this:

* configure driver = { type: 'chrome', userDataDir: 'target/chrome-user-dir' }

You can even set it to null in which case Chrome will use system defaults.

Please follow the instructions here and confirm this works, in which case we can expedite a release: https://github.com/intuit/karate/wiki/Developer-Guide

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
3

The karate 0.95 version, uses a hardcoded way to define it on DriverOptions.java.
So passing this settings to karate, don't work.
Because Chrome.java options.arg("--user-data-dir=" + options.workingDirPath) don't catch it.

So, I just created a batch file to start chrome with my settings, before calling karate.

Add it to your feature, to avoid chrome start:

* configure driver = { type: 'chrome', start: false }

This batch file call chrome with no wait style and call karate after it. I delete my previous reports too.

Batch file:

cd %~dp0

SET PORT=9222
SET AGENT='Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/18.1 Mobile/16B92 Safari/605.1.15'
SET PROFILE="%~dp0\chrome"

DEL "%~dp0\target" /s /q

START "" /D "C:\Program Files (x86)\Google\Chrome\Application\" chrome.exe "--remote-debugging-port=%PORT%" --no-first-run "--user-data-dir=%PROFILE%" --disable-popup-blocking --disable-infobars -–disable-notifications --disable-dev-shm-usage "--user-agent=%AGENT%"

java -jar karate.jar yourtest-01.feature

EDIT: The development version 2.0.0, fixed it.
Just add userDataDir to your configuration.

To build follow instructions here:
https://github.com/intuit/karate/wiki/Developer-Guide#build

Take a look for your own: DriverOptions.java#L170

BTW, I issued a PR to fix when userDataDir is defined, workingDir keeps creating chrome folders with empty content!

Luiz Vaz
  • 1,669
  • 1
  • 19
  • 32