1

Using Karate - geckodriver (Firefox) I need to run it in specific browser window size. According to documentation I have tried (JS configuration file):

karate.configure('driver', { type: 'geckodriver', executable: 'geckodriver', start: false, port: 4444, addOptions: ['windows-size=320,200'] });

or

karate.configure('driver', { type: 'geckodriver', executable: 'geckodriver', start: false, port: 4444, addOptions: ['--windows-size=320,200'] });

No error raised, but window size is not 320,200. Probably there will be some small change in configuration needed.

Thank you for help.

Radim Bukovský
  • 337
  • 2
  • 11

1 Answers1

1

To set the window size, use driver.dimensions any time after the driver has been initialized:

  * driver.dimensions = { x: 0, y: 0, width: 300, height: 800 }

If needed, you can do * driver 'about:blank' before this if you want to start your flow with the browser in a certain size.

If you really mean the display resolution, that is a harder problem. We have a way to do it for the Chrome Docker container by exporting KARATE_WIDTH and KARATE_HEIGHT environment variables. If we get some community help we can do it for FireFox sooner, also based on a Docker container, or you may be able to create one yourself.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • * driver.dimensions works perfectly. Thank you! One additional question - Is it possible to set it somehow in JS configuration file? – Radim Bukovský May 03 '20 at 22:04
  • @RadimBukovský you can, indirectly. set a variable: `config.foo = { x: 0, y: 0, width: 300, height: 300 }` and then in a feature: `* driver.dimensions = foo`. but note that you can use a re-usable feature to init the driver, which can be called from `karate-config.js` - also see this: https://stackoverflow.com/a/60581024/143475 - and `driver.dimensions = {}` will work in JS also, if the driver is ready – Peter Thomas May 04 '20 at 01:56