Deepak N
Deepak N

Reputation: 1639

How to use chromeoption and desirecapabilities in Jmeter Webdriver sampler?

I am using Jmeter webdriver sampler with chrome-browser. I need to use chromeoption and desire capability in jmeter. How to I code to use those options.

example code which I want to use can be this.

ChromeOptions options = new ChromeOptions();
options.addArguments(new String[] {"window-size=12000,10000"});
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(ChromeOptions.CAPABILITY, options);

Can someone help in this.

Upvotes: 1

Views: 2844

Answers (2)

Ori Marko
Ori Marko

Reputation: 58774

You can use the following sample taken from selenium closed issue

options.ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");

// You can cast the ICapabilities object returned by ToCapabilities()
// as DesiredCapabilities. Future .NET bindings releases will likely
// have a copy constructor for this, but this will do for now.
DesiredCapabilities caps = options.ToCapabilities() as DesiredCapabilities;
caps.SetCapability("platform", "VISTA");
caps.SetCapability("version", "{whatever}"";
IWebDriver driver = new RemoteWebDriver(new Uri("{grid location}",

Upvotes: 0

Dmitri T
Dmitri T

Reputation: 167992

Looking into ChromeDriverConfig.java it isn't something you can currently control with the WebDriver Sampler so the options are in:

  1. Patch ChromeDriverConfig source code and amend initialization of the ChromeOptions and DesiredCapabilities according to your needs. Once done you will need to re-build the plugin and put it to "lib/ext" folder of your JMeter installation.
  2. Switch to JSR223 Sampler where you will have full control of the WebDriver instance (however you will need to take care about starting and stopping it, using free ports, etc.). The recommended language for using with JSR223 Sampler is Groovy

Upvotes: 2

Related Questions