Using webdriver plugin in jmeter - selenium

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

Related

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.

Jmeter use Selenium javascript webdriver

All the examples show how to use Selenium Java webdriver with Jmeter.
Can I use Selenium Javascript webdriver with Jmeter?
JavaScript is default language of the WebDriver Sampler
so the answer is yes, you can use JavaScript language for Selenium tests with the WebDriver Sampler.
Check out The WebDriver Sampler: Your Top 10 Questions Answered guide for some code snippets, howtos, tips and tricks

Does browser support WebDriver or does WebDriver support browser

Is it the browser job to support WebDriver or is it WebDriver job to support each browser?
I mean if there is a new release of Chrome does this mean that WebDriver works right away because the support is included in the new Chrome release?
Or is WebDriver support added later by the developers of WebDriver?
To run selenium webdriver in Chrome browser, we need to take the help of ChromeDriver which is a separate executable that selenium webdriver uses to control chrome. ChromeDriver is supported by the Chromium team, ChromeDriver is a standalone server which implements WebDriver's wire protocol for Chromium.
http://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-chrome-browser
Yes, Webdriver made changes later that's the reason new jars of selenium launches so rapidly.
Hope it will help you :)

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.

JUnit Format in WebDriver vs WebDriver Backed

I have recorded a test case in Selenium IDE and want to convert that to Junit. When I try to change through format, I have two options called ‘JUnit WebDriver’ and ‘JUnit WebDriver Backed’. Can you guys please explain me what is the different between this WebDriver and WebDriver Backed? Sorry I am new to Selenium, started learning through Internet Materials.
Thanks,
Abdul Hameed
You use "JUnit WebDriver" if you are using the Selenium 2/WebDriver API. You use "JUnit WebDriver Backed" if you are using the Selenium 1/RC API.
If you switch back and forth you can see the difference in the test method displayed in the IDE window.
More info on the Selenium website here.
The WebDriver Backed JUnit is a hybrid option to allow you continue using the Selenium 1.0 RC while migrating your existing tests to Selenium 2.0 WebDriver