How to run selenium scripts written in java from jmeter?

后端 未结 3 1617
粉色の甜心
粉色の甜心 2021-01-28 09:16

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

3条回答
  •  没有蜡笔的小新
    2021-01-28 09:45

    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.

提交回复
热议问题