7

I have popups with this name structure:

static_dynamic_static

The dynamic part changes each time I log in so my test cases fail each time. I thought about solving the problem with a regular expression like this:

Command: waitForPopUp

Target: regexp:static_.+_static

But this doesn't work. What do I do wrong? Is this even working. If not, is there another way to solve this problem?

Niko Lang
  • 549
  • 1
  • 5
  • 23

3 Answers3

1

From my experience you don't need to declare it as a regex within the target field, you should just be able to have the target as:

static_*_static

and that should do it

Jsmith2800
  • 1,113
  • 1
  • 9
  • 18
0

If you've got only one popup window you can use null as a target and test will take the first popup:

waitForPopup | null

The other option is to get dynamic part before popup opening. It is very likely that the dynamic part could be retrieved from the page. If so you can get it using storeEval, and than use like:

waitForPopup | javascript{'static'+storedVars['dynamic']+'static'}

If you can't store the dynamic part please provide an html of your page or only the part where the dynamic part mentioned.

I see that theoretically it could be possible to get all the names of your windows and than to use pattern in a loop to get the one.

Also (theoretically) it is possible to expand default waitForPopup function.

But the second way and especially the first are much cheaper.

Antesser
  • 669
  • 4
  • 5
0

The best way to handle this might be to run a snippet of javascript to handle this:

<tr>
    <td>storeEval</td>
    <td>var myRe = new RegExp(&quot;^prefix.+&quot;, &quot;g&quot;); var mywin; windows=selenium.getAllWindowNames();for (i = 0; i &lt; windows.length; i++) { if(myRe.test(windows[i])) { mywin=windows[i]}&nbsp;&nbsp;};&nbsp;&nbsp;mywin;</td>
    <td>x</td>
</tr>
<tr>
    <td>selectWindow</td>
    <td>name=${myWindow}</td>
    <td></td>
</tr>

That javascript isn't fully function (no null checking) but should help get you on the right track.

DMart
  • 2,401
  • 1
  • 14
  • 19