I have this selenium test (a part of it).
<tbody>
<tr>
<td>open</td>
<td></td>
<td>localhost:8091</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Rest objects</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[3]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>xpath=(//div[not(div)][1])</td>
<td>ID: 2</td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
</tbody>.
I use Selenium IDE in Firefox. When I run it slowly (toggle speed), it works well. However, when I try to run it faster, I get error at the step <td>clickAndWait</td> after <td>goBack</td>. The log says,
Element xpath=(//a[contains(text(),'Show')])[5] not found.
My questions, how to go back and wait until the page is loaded before I perform other actions.
You have to use waitForPageToLoad command adter click on element till the page loaded and then perform other actions
Use Below code
<tr>
<td>click</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>10000</td>
<td></td>
</tr>
Thanks (#Trimantra Software Solution).
waitForPageToLoad this is what I needed.
From documentation:
waitForPageToLoad(timeout)
Arguments:
timeout - a timeout in milliseconds, after which this command will return with an error
Waits for a new page to load.
This is my solution, I used waitForPageToLoad after goBack.
<tbody>
<tr>
<td>open</td>
<td></td>
<td>localhost:8091</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Rest objects</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[3]</td>
<td></td>
</tr>
<tr>
<td>assertText</td>
<td>xpath=(//div[not(div)][1])</td>
<td>ID: 2</td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>800</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>xpath=(//a[contains(text(),'Show')])[5]</td>
<td></td>
</tr>
<tr>
<td>goBack</td>
<td></td>
<td></td>
</tr>
</tbody>
I see a goBackAndWait() variant of this command. That might work for you.
Typically I'd advise using a waitFor to ensure the page is back to where you want. Simplest that may work is waitForTitle if possible.
waitForElementPresent & waitForText also good ones to look at.
Related
Here is an exerpt from my Selenium script
<tr>
<td>storeElementPresent</td>
<td>css=a.btn.btn-style-c[href="/shortlist/Remove/${codeparc}"]</td>
<td>isSelected</td>
</tr>
<tr>
<td>echo</td>
<td>${isSelected}</td>
<td></td>
</tr>
<tr>
<td>gotoIf</td>
<td>${isSelected}==true</td>
<td>skipToRemoveFromShortlist</td>
</tr>
<tr>
<td>click</td>
<td>css=a.btn.btn-style-c[href="/shortlist/Add/${codeparc}"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=a.btn.btn-style-c[href="/shortlist/Add/${codeparc}"]</td>
<td></td>
</tr>
<tr>
<td>gotoLabel</td>
<td>endOfShortlisting</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>skipToRemoveFromShortlist</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=a.btn.btn-style-c[href="/shortlist/Remove/${codeparc}"]</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>css=a.btn.btn-style-c[href="/shortlist/Remove/${codeparc}"]</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>endOfShortlisting</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=cboxClose</td>
<td></td>
</tr>
Commands 4 and 5 are duplicates
Commands 8 and 9 are duplicates
In step through mode if I execute the command twice it works fine.
Test page for you to look at - www.eurocamp.co.uk/pa012
I'm having trouble getting a link clicked on Selenium IDE.
The id is picked from the itteration in a while loop but i can't get the ID echo'ed in somehow.
This is my code:
<tr>
<td>open</td>
<td>/list</td>
<td></td>
</tr>
<tr>
<td>storeAllLinks</td>
<td>linkArray</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>0</td>
<td>index</td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td><!-- should be array length but that wont word eighter, problem for later -->
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=${index}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
Anny clues on whats going wrong would be great help.
Thank you in advance!
You can locate link by its text. Use of Xpath and link text might help you.
Or please share part of HTML.
The Scenario is,
I recorded the task, which is,
Login, edit a field and save it with different name(but the original field remains),logout.
Here i need to manipulate the 'name' field, so i can get 100 or more copies of it, with unique names.
Is it possible in Selenium IDE?, if not , is there any open source tool available to do the same?
</thead><tbody>
<tr>
<td>open</td>
<td>/SurveyHome.aspx</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_gvSurvey_ctl02</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=ctl00_ContentPlaceHolder1_txtsurname</td>
<td>Survey 1</td> // This is the name of the survey.
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_btncopysurok</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>id=ctl00_ContentPlaceHolder1_btncopyok</td>
<td></td>
</tr>
</tbody></table>
How to use the while loop in this code, i tried using but, the selenium ide is not recognising it.Can you plz help me with this..
You can use while loop for your purpose
<tr>
<td>getEval</td>
<td>index = 1;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 10;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>survey ${value}</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
in the name text box field you give the value has survey ${value},
now you can create any number of form with unique name by
using this while loop put your form inside this while loop.
Try it
Thank you.
<tr>
<td>open</td>
<td>/SurveyHome.aspx</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index = 1;</td>
<td></td>
</tr>
<tr>
<td>while</td>
<td>index < 100;</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>index</td>
<td>value</td>
</tr>
<tr>
<td>echo</td>
<td>survey ${value}</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=ctl00_ContentPlaceHolder1_gvSurvey_ctl02</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=ctl00_ContentPlaceHolder1_txtsurname</td>
<td>survey ${value}</td>
</tr>
<tr>
<td>click</td>
<td>id=ctl00_ContentPlaceHolder1_btncopyok</td>
<td></td>
</tr>
<tr>
<td>getEval</td>
<td>index++;</td>
<td></td>
</tr>
<tr>
<td>endWhile</td>
<td></td>
<td></td>
</tr>
try it.
thank you
I am using Selenium IDE for some tests. But hardly stuck with one action - i need to close a download pop up window in FF.
Common way to perform this would be using selectWindow command, BUT - my pop up - it's actually a frame, so it does not have an ID and other useful parameters for IDE.
All my attempts to close this pop up lead to closing main window.
I tried something like this, but did not work either:
<tr>
<td>click</td>
<td>css=#fpm > img</td>
<td></td>
</tr>
<tr>
<td>waitForFrameToLoad</td>
<td>http://www.somesite.com/lg/c.do?proj=1111&aid=1111&rnd=0.132456</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>5000</td>
<td></td>
</tr>
<tr>
<td>close</td>
<td></td>
<td></td>
</tr>
<tr>
Is anybody faced this problem in the past? I know, that JS can be used at this point, but i don't have any clue how. Can you advise?
Finally, i found a way...
Bit tricky, but it works. So, this was an IDE bug, where IDE is unable to identify opened "_blank" windows. Here is workaround:
<tr>
<td>storeAttribute</td>
<td>//a[#'Here you can use id/class/href/rel link, etc, for ex: #rel='Register']/#href</td>
<td>href</td>
</tr>
<tr>
<td>openWindow</td>
<td>${href}</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>storeEval</td>
<td>selenium.getAllWindowNames()[1];</td> -- [1] - window to select from array of window names, 0 - it's a main, 1 - 1st opened pop up, 2 - 2nd, etc.
<td>windowName</td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>selectWindow</td>
<td>${windowName}</td>
<td></td>
</tr>
<tr>
<td>verifyElementPresent</td>
<td>Verify something here</td>
<td></td>
</tr>
<tr>
<td>close</td> -- close pop up
<td></td>
<td></td>
</tr>
<tr>
<td>selectWindow</td> -- return to main window
<td>null</td>
<td></td>
</tr>
I'm trying to use Selenium IDE to test a web app. On one page, there are several links which trigger modal windows. I'd like to test ALL the links on the page to ensure that ALL cause modals to pop up.
Each link has a class "modal" so I thought I could just change the target value in IDE css=a.modal but that finds only the first link.
I've found a few solutions but they use Selenium RC with Java/Python and those can't be directly translated to the IDE.
I understand the IDE is not as powerful but I'm setting this up for a non-programmer to use and up till now, it's been really simple for them.
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).