Parse URLs for Request Values ​​with Selenium IDE

I am new to integration testing, but still have had great success creating a test suite using the Se: IDE. Since I was doing my tests, it occurred to me that I was generating a significant amount of data, and I would like to clear it after myself.

Most of my tests include creating a new "page", and the identifier is available in the request. I would like the Se: IDE to save the querystring value and pass it to another page that calls the delete method to tidy up after performing my checks.

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

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

+3
source share
3 answers

If you save all your test cases in one test suite. They can share variables between executions without problems. So all you have to do is save the desired value:

storeLocation | variable | |

and in a future test you should use the following variable:

open | ${variable} | |

Note. For more information on test suites, see: http://seleniumhq.org/docs/03_selenium_ide.html#writing-a-test-suite

Update:

Now you can use javascript regular expressions to get a substring from a variable:

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

An example :

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

output:

[info] echo: 012la 
+5

, Q & . URL- aspx .

(1) storeLocation, storeEval verifyExpression. (2) HTMLsource

<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>
+3

A quick example to extract the id parameter from the query string:

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 this is not the case, you can better divide the location by '&' and loop the resulting array for the id parameter value.

+2
source

Source: https://habr.com/ru/post/1716844/


All Articles