Using Selenium with JMeter

To use Selenium Webdriver with JMeter, install “Webdriver” plugins. The WebDriver sampler is useful if you want to test for performance AJAX or GWT based web applications.

Download WebDriver plugins from http://jmeter-plugins.org/downloads/all/

Unzip the files and copy in the lib folder under JMeter home directory.

To test if WebDriver plugins installed open Jmeter and test if there is jp@gc – Firefox Driver Config.

*If not, check your JMeter’s lib folder.
 Selenium Webdriver SamplerAdd the Webdriver sampler and Firefox or chrome driver config element. Insert the following code to launch Bing search and search for a text. Also add tree listener to view the result.
var pkg = JavaImporter(org.openqa.selenium)
var support_ui = JavaImporter(org.openqa.selenium.support.ui.WebDriverWait)
var wait = new support_ui.WebDriverWait(WDS.browser, 20000)
WDS.sampleResult.sampleStart()
WDS.browser.get('http://www.bing.com/')
var searchField = WDS.browser.findElement(pkg.By.id('sb_form_q'))
searchField.click()
searchField.sendKeys(['testing'])
var button = WDS.browser.findElement(pkg.By.id('sb_form_go'))
button.click()
WDS.sampleResult.sampleEnd()
selenium_jmeter_2
Explanation of the code
  • The code starts with the import Java packages “org.openqa.selenium” and “org.openqa.selenium.support.ui.WebDriverWait” which will allow you to use the WebDriver classes.
  • WDS.sampleResult.sampleStart() and WDS.sampleResult.sampleEnd() captures sampler’s time and will track it. You can remove them, the script will still work but you will not get load time
  • WDS.browser.get(‘http://www.bing.com/’) – opens the browser with Bing search website
  • var searchField = WDS.browser.findElement(pkg.By.id(‘sb_form_q’)) – saves the search text box in searchField varialble
  • searchField.click() – Clicks the search field to make it active
  • searchField.sendKeys([‘testing’]) – Enters text to search
  • var button = WDS.browser.findElement(pkg.By.id(‘sb_form_go’)) – Saves search button in a variable
  • button.click() – clicks on the search button.

You are now ready to go. Do let us know your experience in using Selenium with JMeter

Monitoring windows server using JMeter plugin

JMeter plugin is the very much usefull in load testing. Long time back I had posted an article for monitoring windows server using Nagios. Now you do not require Nagios any more.  A JMeter plugin is available which can be used with JMeter to perform this. This plugin integrates with the JMeter tool.To install the JMeter Plugins, you simply have to copy the JMeterPlugins.jar file from JMeterPlugins-VERSION.zip inside JMETER_INSTALL_DIR/lib/ext. Now you can restart your JMeter and see jp@gc-prefixed plugins in menus.
The plugin can be downloaded from http://code.google.com/p/jmeter-plugins/downloads/detail?name=JMeterPlugins-0.5.6.zipTo use the the Servers Monitoring Listener, you must also install the server agent on all servers which need to be monitored.You need to run JMeter 2.4 or above with a JRE 1.6 or above to use the plugin.
Jmeter_Plugin_perfmon
Update[20-Oct-2013]: The latest version of JMeter plugin is 1.1.1. and can be downloaded from the following location.
http://jmeter-plugins.org/
It requires JMeter 2.8 or above and JRE 1.6 or above.