TestProject Forum
Powered by leading experts in the test automation community

How to run selenium script in Jmeter

I want to run selenium script in Jmeter. Is it possible or not ?

  1. Download Webdriver plugin https://jmeter-plugins.org/downloads/all/ and move to lib/ folder.

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

  3. 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()

  4. Execute your test

Hi Mark,

Thanks for your reply. I am using java language for script development, so can i use same plugin for java language ?

Regards,
Poovaraj