Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

I have Selenium automation scripts ready with the functional flow, now I want to integrate those scripts with JMeter for load-testing.
Is this possible?
If so how to integrate both?

My first aim is to run the automation script using selenium than run those scripts in JMeter for load or performance testing.

1 Answer

0 votes
by (62.9k points)

There is an easier way to run Selenium scripts.

  1. Download WebDriver plugin and move to lib/ folder.

  2. Add jp@gc - Firefox Driver Config and jp@gc - Web Driver Sampler to your test tree

Jmeter test tree

  • Add this code

var pkg = JavaImporter(org.openqa.selenium) var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait) var wait = new support_ui.WebDriverWait(WDS.browser, 5000) WDS.sampleResult.sampleStart() WDS.log.info("Opening page..."); WDS.browser.get('http://duckduckgo.com') var searchField = WDS.browser.findElement(pkg.By.id('search_form_input_homepage')) searchField.click() WDS.log.info("Clicked search field") searchField.sendKeys(['blazemeter']) WDS.log.info("Inserted blazemeter keyword") var button = WDS.browser.findElement(pkg.By.id('search_button_homepage')) button.click() WDS.log.info("Clicked search button"); var link = WDS.browser.findElement(pkg.By.ByCssSelector('#r1-0 > div.links_main > h2 > a.large > b')) link.click() WDS.log.info("Clicked blazemeter link"); WDS.log.info(WDS.name + ' finishing...'); WDS.sampleResult.sampleEnd()

  • Run your test

For more detailed information about code syntax and best practices you can try Using Selenium with JMeter's WebDriver Sampler article.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...