How to use selenium3 in jmeter webdriver Sampler - selenium

I use JMeter4 + Selenium2 + Firefox 45 in webdriver sampler to test GUI. This works well, but if we want to test the new version of Firefox (for example, version 55), we need to install Selenium 3. The JMeter webdriver plugin (version 2.3) requires Selenium 2.
How can I make webdriver sampler + selenium 3 work in jmeter?

You will not able to use current WebDriver Sampler version with Selenium 3.x as it relies on some Selenium API which has incompatible changes, even if you upgrade Selenium libraries the WebDriver Sampler will not work.
However you can try the following approach:
Uninstall WebDriver Sampler and all its dependencies (or even better obtain a fresh copy of JMeter)
Download Selenium 3 client .jar(s) and put them into JMeter Classpath
Write your Selenium-related code using JSR223 Sampler or JUnit Request sampler
You can also reach out WebDriver Sampler plugin developers/maintainers and clarify when/if support of newer Selenium version will be added at JMeter Plugins Support Forum

Related

Using webdriver plugin in jmeter

Iam trying to use webdriver plugin to automate an application in jmeter. Can anyone help me to do scripting in selenium by using webdriver plugin. Thanks in advance.
It depends on the browser and programming language you're using.
Currently Chrome is the most popular browser and JavaScript is the default language for the WebDriver Sampler so:
Download chromedriver (make sure that the version you download matches your Chrome browser version)
Add Chrome Driver Config and specify the path to the chromedriver in the "Chrome" tab:
Add WebDriver Sampler and implement the code for your test scenario. WDS.browser will stand for the ChromeDriver instance so you will be able to: use
WDS.browser.get('some url') - open a page
var element = WDS.browser.findElement(org.openqa.selenium.By.id('some id')) - locate a WebElement
element.click() - click the element found in the previous step
etc.
More information: The WebDriver Sampler: Your Top 10 Questions Answered

JMeter WebDriver Sampler - headless Firefox

Is it possible to run Firefox headless with WebDriver Sampler? I have used the "Use Chrome headless mode" option with Chrome before, but I don't see that option in Firefox Driver Config.
Perhaps this can be done in the actual sampler, by setting options to 'browser' in the code below?
WDS.sampleResult.sampleStart()
WDS.browser.get('http://jmeter-plugins.org')
WDS.sampleResult.sampleEnd()
Thank you.
There is no easy/GUI way of doing this using WebDriver Sampler (unless you patch FirefoxDriverConfig to include FirefoxBinary and pass to it --headless argument like:
FirefoxBinary firefoxBinary = new FirefoxBinary();
firefoxBinary.addCommandLineOptions("--headless");
Another option would be switching to JSR223 Sampler to initialise the FirefoxDriver class yourself from the scratch.
More information: Firefox - Headless Mode
And last but not the least, if you're about to execute your Selenium tests on i.e. Linux machine which doesn't have GUI you can create a virtual display using Xvfb so Firefox would run attached to this virtual desktop. See Headless Execution of Selenium Tests in Jenkins for more details on implementing this on different operating systems.

When replacing selenium jars with latest version under JMeter lib folder 'ConversionException' is thrown

I am working with JMeter and Selenium. Installed the plugins manager and via that, installed web-driver sampler. When I look into lib folder, I found the selenium jars version are 2.52.0 which is much older. I can able to work with that without any issues. But the real problem is:
Using Maven, I updated all the selenium jars to 3.9.1 version and its dependant jars like guava, gson, commons, etc.
Now, when I open the jmx files with WebDriver sampler and driver configs, I receive below error.
Using maven, I mean, I downloaded all the jars from maven repo manually and pasted into JMeter lib folder.
Please help me to work with latest Selenium drivers in JMeter.
You won't be able to use WebDriver Sampler plugin with Selenium 3.9.1 as it explicitly relies on SessionNotFoundException class which has been removed in the latest Selenium libraries.
So the options are in:
Use WebDriver Sampler with browser version(s) supported by Selenium 2.52.0
Reach out to WebDriver Sampler plugin developers and/or maintainers at jmeter-plugins forum to check whether it is planned to update Selenium libraries and if yes - when. You can also update WebDriver Sampler source code by yourself and send pull request to the plugin maintainer.
Switch to JSR223 Sampler and Groovy language instead. Apart from being able to use latest libraries you will have full control of the WebDriver instance using DesiredCapabilities at full instead of limited subset exposed via *Driver Config elements.

Not able to run webdriver scripts from jmeter

I am trying to execute webdriver script from jmeter.
I have installed webdriver plugin.
Created firefox config element and web driver sampler.
Added script under webdriver sampler -
WDS.sampleResult.sampleStart()
WDS.browser.get('http://google.com')
WDS.sampleResult.sampleEnd()
But while executing, browser is not opening.
I'm pretty much sure that you have Firefox version which is not supported by underlying Selenium libraries.
WebDriver Sampler plugin 1.2.1 supports Firefox 33
WebDriver Sampler plugin 1.2.0 supports Firefox 26
If you need the latest Firefox for any other reason you can have Firefox 26 or 33 installed somewhere else. Just add the following line to system.properties file (lives under /bin folder of your JMeter installation)
webdriver.firefox.bin=/path/to/your/firefox/directory
See The WebDriver Sampler: Your Top 10 Questions Answered guide for more WebDriver sampler tips and tricks.
Jmeter only supports some of the versions of Firefox to run Jmeter-webdriver script. Use firefox 45.0 it will work like pro.
The Installation of firefox should be in the default directory, do not custome the path of Firefox 45.0.

selenium webdriver: mouseOver and PHPUnit

How can I use action mouseOver() with PHPUnit in my tests?
I can't find information about it.. Only using of java class Action.
Unfortunately the Selenium 2 WebDriver is not supported by the existing Selenium extension for PHPUnit (only the deprecated Selenium RC is). Refer to thread Selenium 2 (WebDriver) and Phpunit?, it's from a year ago but still valid.
Check this post out for alternatives.