3

I'm new to integration testing, but have had great success so far buiding up a suite of tests using Se:IDE. As I've been running my tests, it has occurred to me that I'm generating a substantial amount of data and I'd like to clean up after myself.

Most of my tests involve creating a new 'page', and the id is available in the querystring. I'd like to have Se:IDE store a querystring value and pass it to another page that calls a delete method to tidy up after I have run my verifications.

I see that I can use the command storeLocation, but I'm not sure how I would go about parsing that value for the id in the querystring, and then pass it to another page using Open.

Have I reached the point where I need to migrate my tests to c#, or is this possible using the IDE?

3 Answers 3

5

If you keep all your test cases inside the same test suite. They can share variables between executions without problems. So, all you have to do is to store the desired value:

storeLocation | variable | |

and in a future test, you have to use the variable as the following:

open | ${variable} | |

Note: for more info on test suites, take a look at: http://seleniumhq.org/docs/03_selenium_ide.html#writing-a-test-suite

Update:

You can now use javascript regular expressions to get a substring from a variable:

storeEval | reg = /substring pattern/;reg.exec(${variable}) | substring
open | ${substring} | |

Example:

store | "012la4la" | a
storeEval | re = /[0-3]*la/;re.exec(${a}) | new
echo | ${new} | 

output:

[info] echo: 012la 
Sign up to request clarification or add additional context in comments.

4 Comments

While that's very handy to know, I still have the issue of parsing the URL that is stored in ${variable} for the querystring value. Either I need a method which can return the querystring value, or some way to parse ${variable} with a regular expression.
Updated the post in case you needed to parse it using regexp
Santi's regular expression solution is somewhat more elegant than mine. Cheers Santi.
I had to quote the variable in the target expression to avoid an exception: reg = /substring pattern/;reg.exec('${variable}')
3

I had a similar issue at work, and this Q&A blog helped me out a lot. In my case, I had to strip query string parameters from an aspx URL, and verify their existence.

And I used a 2 stage filter approach for verification (1) storeLocation, storeEval and verifyExpression. (2) verifyHTMLsource and globbing the string

<tr>
    <td>verifyLocation</td>
    <td>http://qa.clockstock.com/confirmation.aspx?exrc=90210&amp;csrc=</td>
    <td></td>
</tr>
<tr>
    <td>storeLocation</td>
    <td>urlconf</td>
    <td></td>
</tr>
<tr>
    <td>echo</td>
    <td>${urlconf}</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>storedVars['urlconf'].indexOf('exrc=90210');</td>
    <td>exrcurlconf</td>
</tr>
<tr>
    <td>verifyExpression</td>
    <td>javascript{(storedVars['CIDurlconf']&gt;0)}</td>
    <td>true</td>
</tr>
<tr>
    <td>storeEval</td>
    <td>storedVars['urlconf'].indexOf('csrc=');</td>
    <td>CSRCurlconf</td>
</tr>
<tr>
    <td>verifyExpression</td>
    <td>javascript{(storedVars['CSRCurlconf']&gt;0)}</td>
    <td>true</td>
</tr>
<tr>
    <td>verifyHtmlSource</td>
    <td>glob:*confirmation.aspx*exrc=90210*csrc=*</td>
    <td></td>
</tr>

Comments

2

A quick example for extracting an id parameter from a query string would be:

storeLocation | myLocation
store | javascript{ storedVars['myLocation'].substring(storedVars['myLocation'].indexOf('id=')+3, storedVars['myLocation'].length); } | idValue

This assumes that the id parameter is the last in the query string. If it's not then you might be best splitting the location on '&' and looping through the resulting array for the 'id' parameter value.

2 Comments

Do I run the javascript from the Value textbox?
Ah figured it out, I need to use storeEval to run javascript against the stored variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.