How to user parameterisation in selenium webdriver and jmeter integration

1,677 views
Skip to first unread message

kesha...@gmail.com

unread,
Jan 17, 2014, 7:10:48 AM1/17/14
to jmeter-...@googlegroups.com
Hi All,

I am new to Jmeter, i am trying to use webdriver with jmeter.

I want to test the performance with login functionality with my application

Can any one help me how to use parameterisation for user name and password to test different users logging in simultaneously scenario.

Please help.

Thanks in advance 

vdab...@gmail.com

unread,
Jan 20, 2014, 6:12:28 AM1/20/14
to jmeter-...@googlegroups.com
Hi,

Look at the documentation, chapter  "Parameters and args"
http://jmeter-plugins.org/wiki/WebDriverSampler/


Extract from my contribution for the thread discussion forum "Contributing a Web Driver (Browser) based Sampler"
=================================================================================================================
Hi

I found a way to pass parameters containing spaces as a single parameter in Webdrivers Sampler or Javascript Sampler generally.

My parameter called P_TITLE have the value "Welcome page" (with space character)

I replace all space characters with another character, i choose the # character.

So, in the Webdriver Sampler, i want to pass the modified P_TITLE like this
Parameters = ${__javaScript("${P_TITLE}".split(' ').join('#'))}

And in the script
var TITLE_WITH_SHARP = WDS.args[0];
WDS.log.info("TITLE_WITH_SHARP = " + TITLE_WITH_SHARP);  ==> Welcome#page

// replace # by space
var TITLE = TITLE_WITH_SHARP.split('#').join(' ');

WDS.log.info("TITLE = " + TITLE) ==> Welcome page

Regards
Vincent D.
=================================================================================================================

Hi,

I find a solution to return information or data from a webdriver sampler outside this current webdriver sampler.
This solution uses a sub sample result to store information and this new sub sample result is add to the current sampler.

Example, who transmits the title of the current page and get the title with Regular Expression Extractor :
== 1 =======================================================================
// 1a. Start capturing the sampler timing
WDS.sampleResult.sampleStart()

// 2. Perform the Sampler task
WDS.browser.get('http://host:8080/gestdocqualif/')

// 1b. Stop the sampler timing
WDS.sampleResult.sampleEnd()

// 3. Verify the results
var stringToFind = "Page d'accueil application";
if(!WDS.browser.getTitle().match(stringToFind)) {
    WDS.sampleResult.setSuccessful(false)
    WDS.sampleResult.setResponseMessage("Expected title to be <" + stringToFind + ">")
}
else {
    WDS.log.info("In the expected page");
  
    // create a subSampleResult to transmit information from WebDriver easily retrievable
    var sampleResultSub = new org.apache.jmeter.samplers.SampleResult();
  
    // value to transmit, here is the title read by driver.getTitle()
    var sResultToTransmit = WDS.browser.getTitle();
    sampleResultSub.setResponseData(sResultToTransmit);
    sampleResultSub.setSampleLabel("SubResultToTransmitInfo");
    sampleResultSub.setSuccessful(true);
    sampleResultSub.setContentType("text/plain");
    // sampleResultSub.setDataEncoding("ISO-8895-1");
    WDS.sampleResult.addSubResult(sampleResultSub)
}
=== 2 =============================================================================
Add a child Regular Expression Extractor to the webdriver sampler like this (look at the screenshot)
Name : regEx Read Value from the SubSampleResult
Apply to : check Sub-samples only
Response field to check : Body
Reference name : P_TITLE
Regular expression : (.*)
Template : $1$
Matches no : 1
Default value : P_TITLE_NOT_FOUND
==========================================

The variable called P_TITLE contents the title of the page. The title is get by a webdriver function WDS.browser.getTitle()

But i have now a little issue to passe the title to another webdriver sampler because the title contents space chars.
In a second Webdriver sampler > Parameters : ${P_TITLE}
In the script :
WDS.log.info("Nb args = " + WDS.args.length); => 5 args !


Regards
Vincent D.

Andrey Pohilko

unread,
Jul 24, 2014, 1:57:33 AM7/24/14
to jmeter-...@googlegroups.com
BTW, version 1.1.4 will have  WDS.sampleResult.subSampleStart() and  WDS.sampleResult.subSampleEnd() methods for the convenience.

понедельник, 20 января 2014 г., 13:12:28 UTC+2 пользователь Vincent Daburon написал:
Reply all
Reply to author
Forward
0 new messages