Share
Go down
guicps89
Posts : 5
Join date : 2013-03-14

clickAndWait with loop

on Thu Mar 14, 2013 8:50 pm
Hi everyone,

I'm using Selenium IDE and there is a step on my code that needs to click on a link called "Approve".
The problem is that this link may appear up to 4 times (you click once, the page is refreshed and the link appears again). So, I need to know if there is a way to create a loop to my script click on this link while it exists, and if it is not found anymore, continue to execute the next steps.

Currently, I'm using like this:

COMMAND | TARGET
clickAndWait | link=Approve
clickAndWait | link=Approve
clickAndWait | link=Approve
clickAndWait | link=Approve

I put it 4 times in a row, but if the links appears just 3 times, for example, the 4th command gets error because it did not find the link and stops the script and don't execute the other next steps.
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 33
Location : Denver, CO

Re: clickAndWait with loop

on Wed Mar 20, 2013 1:45 am
storeElementPresent | link=Approve | linkExists
while | storedVars.linkExists |
clickAndWait | link=Approve
storeElementPresent | link=Approve | linkExists
endWhile |

Let me know if this doesn't work
guicps89
Posts : 5
Join date : 2013-03-14

Re: clickAndWait with loop

on Wed Mar 20, 2013 2:37 am
It worked, I did like this, thanks a lot:

storeElementPresent | link=Approve | ApproveTrue
while | ${ApproveTrue} == true |
clickAndWait | link=Approve
storeElementPresent | link=Approve | ApproveTrue
endWhile | |
sunny mehndiratta
Regular Participant
Regular Participant
Posts : 25
Join date : 2013-03-22

Re: clickAndWait with loop

on Fri Mar 22, 2013 4:28 pm
guicps89 wrote:It worked, I did like this, thanks a lot:

storeElementPresent | link=Approve | ApproveTrue
while | ${ApproveTrue} == true |
clickAndWait | link=Approve
storeElementPresent | link=Approve | ApproveTrue
endWhile | |



y did u add this line again in ur code.can u help me out

storeElementPresent | link=Approve | ApproveTrue
guicps89
Posts : 5
Join date : 2013-03-14

Re: clickAndWait with loop

on Fri Mar 22, 2013 6:47 pm
y did u add this line again in ur code.can u help me out

Hi sunny,

The first time that this line appears is to check if the link "approve" exists, and if it exists, it enters in the While loop and execute the commands. Once this is a While loop, it must have a condition to stop, or it will loop forever. That's why this line you mentioned appears 2 times, the second time is to check again if this link still exists, and if not, it will exit the loop.
sunny mehndiratta
Regular Participant
Regular Participant
Posts : 25
Join date : 2013-03-22

Re: clickAndWait with loop

on Sat Mar 23, 2013 1:39 am
thanks for the solution
Sponsored content

Re: clickAndWait with loop

Back to top
Permissions in this forum:
You cannot reply to topics in this forum