Selenium IDE - "runScript" command example to split drop down label string

"runScript" command Example 1 and Example 2 will describe you how to generate alert message in selenium IDE. Now let we go at next step. Supposing i have a drop down containing labels Volvo, Saab, Opel, Audi, Toyota and Renault. I want to pick one specific label from it to store it in to variable to
use at some other place. How can i do it?  Bellow given example will provide you a solution.

Example 3 : "runScript" Command To Split Values Which Are Stored Using "storeSelectOptions"

New Test
CommandTargetValue
openhttp://only-testing-blog.blogspot.com
/2013/10/table.html

storeSelectOptionscss=selectvalues
echo${values}
runScriptjavascript
{storedVars['values'].splice(0,4)}

echo${values}
runScriptjavascript
{storedVars['values'].splice(1,2)}

echo${values}

Looking for more examples of "runScript" command? Click Here

In this example, 1st "runScript" command will differentiate last 2 values (Toyota,Renault ) from all value string and store it in variable 'values'. And 2nd "runScript" command will split 1st value (Toyota) and store it in variable 'values'. This way you can store your required value from drop down to variable.

1 comment: