Selenium IDE testing all links Selenium IDE testing all links selenium selenium

Selenium IDE testing all links


i had to read up a lot and i want to thank @ohaal and @aleh for their inputs. i used their suggested links as well as some more external reading to reach the solution like so:

<tr><td>open</td><td>/logout</td><td></td></tr><tr><td>clickAndWait</td><td>link=Forum</td><td></td></tr><tr><td>storeXpathCount</td><td>//p[3]/span/a[contains(@class, 'modal')]</td><td>users</td></tr><tr><td>store</td><td>1</td><td>i</td></tr><tr><td>while</td><td>storedVars.i<=storedVars.users</td><td></td></tr><tr><td>click</td><td>//descendant::a[contains(@class, 'modal')][${i}]</td><td></td></tr><tr><td>waitForText</td><td>css=h2</td><td>You are not logged in</td></tr><tr><td>click</td><td>css=#cross_button > a > img</td><td></td></tr><tr><td>store</td><td>javascript{storedVars.i++}</td><td></td></tr><tr><td>endWhile</td><td></td><td></td></tr>

i'm not selecting any one answer as all of them contributed to the final solution.


Use a while loop, and this XPath expression as a locator: //a[contains(@class, 'modal')]

//a[contains(@class, 'modal')][1], //a[contains(@class, 'modal')][2] and so on should point to the links you're after.

See this link for more information on how to do while loops in Selenium IDE if you are unfamiliar with it.


Try this (you have to download this extension):

<tr>    <td>storeCssCount</td>    <td>css=a.modal</td>    <td>links</td></tr><tr>    <td>store</td>    <td>0</td>    <td>i</td></tr><tr>    <td>label</td>    <td>l1</td>    <td></td></tr><tr>    <td>getEval</td>    <td>storedVars.i++</td>    <td></td></tr><tr>    <td>click</td>    <td>//descendant::a[contains(@class, 'modal')][${i}]</td>    <td></td></tr><tr>    <td>gotoIf</td>    <td>--storedVars.links</td>    <td>l1</td></tr>

Insert your assertions and probably pop-ups closings before last command (gotoIf).