Using gotoIf AND contains

Tags: 

Here is how you would use a gotoIf where a variable contains a text string:

storeLocation currentLocation  
storeEval javascript{storedVars['currentLocation'].contains("gateway.zscaler.net");} myResult
gotoIf ${myResult} == false skipZScalerLogin

Or, matches a text string variable:

<tr>
    <td>storeLocation</td>
    <td>whereAmI</td>
    <td></td>
</tr>
<tr>
    <td>storeEval</td>
    <td>javascript{storedVars['whereAmI'].match(storedVars['testSetPage']);}</td>
    <td>myResult</td>
</tr>
<tr>
    <td>gotoIf</td>
    <td>${myResult} == false</td>
    <td>quitSuite</td>
</tr>

I used this snippet of code to test the current location (URL) of the browser during a test. If the current location didnt match what I expected, I could redirect (gotoIf) the script to another part of the code.