WebDriver Sampler - How to use parameters containing spaces

594 views
Skip to first unread message

Auro

unread,
Jul 6, 2016, 9:59:25 AM7/6/16
to jmeter-plugins
Hi Guys, I'm having problmes using parameters with webdriver sampler:

from the guide:
  1. WDS.parameters - is the value provided in the Parameters field (above).
  2. WDS.args - is an array of the strings provided in the Parameters field, but split by the space ' ' character. This allows the scripter to provide a number of strings as input and access each one by position.
in particular I have two parameters:

string1=passed
string2=not passed

in this case the sampler will manage three parameters instead of two.

 WDS.args[0]=passed
 WDS.args[1]=not
 WDS.args[2]=passed

this is because string2 contains a space...is there a way to avoid this and have  WDS.args[1]=not passed ? I tried escaping the space with \ but it doesn't work

Auro

unread,
Jul 6, 2016, 10:09:35 AM7/6/16
to jmeter-plugins
I found a workaround..just avoiding WDS.parameters.

I could use "${string2}" directly on the script

Vincent Daburon

unread,
Jul 7, 2016, 5:21:42 AM7/7/16
to jmeter-plugins
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
Reply all
Reply to author
Forward
0 new messages