Reputation: 151
I am using selenium to test number of web pages in one test suite. is there any way of parameterizing the urls? I tried doing it using javascript file, like, added url in js file, and used that variable in href tag.
Upvotes: 0
Views: 514
Reputation: 2002
Use below code for same with js file which include var URL=new Array("www.asd.com","www.asd.com","www.asdd.com","www.asdsa.com","www.asdda.com");
<tr>
<td>store</td>
<td>0</td>
<td>looptimes</td>
</tr>
<tr>
<td>while</td>
<td>storedVars.looptimes <= 1</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>alert("start")</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>URL[storedVars.looptimes]</td>
<td>URL</td>
</tr>
<tr>
<td>open</td>
<td>${URL} </td>
</tr>
<tr>
<td>store</td>
<td>javascript{storedVars.looptimes++;}</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
Upvotes: 1
Reputation: 61
Check this: http://saucelabs.com/blog/index.php/2011/01/selenium-resources-for-newbs-data-driven-testing-with-ide-xml/
Using this solution you can run each test case in a loop (each time using different url) then selenium will switch to next test case in test suite...
Test case would look like this:
loadTestData | file:///listofURLs.xml
while | !testdata.EOF()
nextTestData |
open | ${variableURL}
verifyTextPresent | sometext
verifyTextPresent | sometext
endWhile |
Upvotes: 0