I am trying to use my Selenium scripts in java with JMeter\'s WebDriver Sampler.
Inside the webdriver sampler, the language is seleced to java, and the following code
Another way you could do this is extract you webdriver test in a jar file then run in using a junit test in JMeter.
You should not be instantiating WebDriver instance, JMeter does it for you given you add Chrome Driver Config element to your Test Plan and configure path to the ChromeDriver executable.
Once done you should be able to use WDS.browser
shorthand like:
WDS.sampleResult.sampleStart();
WDS.browser.get("http://google.com");
WDS.log.info("Successfully opened the website www.google.com");
Thread.sleep(5000);
WDS.sampleResult.sampleEnd();
Also don't call quit()
method, the WebDriver instance(s) will be shut down when test will be finished.
See Using Selenium with JMeter's WebDriver Sampler guide to get started with Selenium and JMeter integration.
If you are using Chrome driver 2.28 with Selenium 3.x.x you have to set the path of the Chrome driver before you open the browser.
Add this line:
System.setProperty("webdriver.chrome.driver", "C:\\your_folder\\chrome.exe");
Next, WebDriver driver;
Let me know if this helps you.