Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
anbarasi
Amateur
Amateur
Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai

how to call single code multiple times? Empty how to call single code multiple times?

Fri Apr 12, 2013 11:19 am
hi can anybody tell how to proceed following ....

my application is have to click a drop down which has nearly 150 options and select each of them and add to the database... instead of repeating the same steps 150 times i need to do in a single step with those 150 values calling ...
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

how to call single code multiple times? Empty Re: how to call single code multiple times?

Fri Apr 12, 2013 10:38 pm
store | 0 | i
while | ${i}<150 |
select | drop down name| index = ${i}
//And whatever other steps you need to add to the DB
store | javascript {storedVars.i++}
endWhile

if the first option in your drop down is not a valid option(typically it is something like "Select an Option") then set 'i' to 1 instead of 0 and change your while condition to ${i}<=150
avatar
anbarasi
Amateur
Amateur
Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai

how to call single code multiple times? Empty Re: how to call single code multiple times?

Mon Apr 15, 2013 4:23 pm
hi .... its executing many times but i want to randomly select the options start from 1 to 150 options . now in this above code i can perform only first number 1 option , remaining 149 i could not do .

plz help
avatar
anbarasi
Amateur
Amateur
Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai

how to call single code multiple times? Empty Re: how to call single code multiple times?

Mon Apr 15, 2013 6:41 pm
need to change that store |1|i command , like to store 2 then 3 etc..
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

how to call single code multiple times? Empty Re: how to call single code multiple times?

Mon Apr 15, 2013 9:46 pm
anbarasi wrote:need to change that store |1|i command , like to store 2 then 3 etc..

That is exactly what store| javascript{storedVars.i++} does! It increments i each time the loop is ran. Since that store|1|i command is outside of the loop, it will not be executed again, which is why we update i within the loop. Is it not updating the value of i? Put in an echo command in there to see if it is outputting the correct value. If you can, post your code.

Also make sure you can select from your drop down by the index.

To do this randomly you will need a lot more logic to store what numbers you have already selected and make sure you do not select them again, unless you don't care about selecting duplicates.
avatar
anbarasi
Amateur
Amateur
Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai

how to call single code multiple times? Empty Re: how to call single code multiple times?

Tue Apr 16, 2013 6:46 pm
yes the echo command shows the count .

my code is

select
name=servertypes
index=1 /// here i have till 150 options
// then im selecting that option and adding to the db


now my script has to ask the user which option they need to add if the user says option 2 i have make the script to choose the index=2 and proceed the steps adding to the db. again then i have to ask the user whether they need to add any option more if they say yes and gives any option my script has to go to that option again. no matter of duplicates.
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

how to call single code multiple times? Empty Re: how to call single code multiple times?

Wed Apr 17, 2013 10:01 pm
Correct me if I'm wrong, but you want a js pop-up where you can just enter the index of the option?

storeEval | prompt("Enter the index") | index
select | name = servertypes | index=${index}

If you want to wrap that into a loop you can do this:
store | 0 | i
while | ${i}<150 |
storeEval | prompt("Enter the index") | index
select | name = servertypes | index=${index}
//And whatever other steps you need to add to the DB
store | javascript {storedVars.i++}
endWhile
avatar
anbarasi
Amateur
Amateur
Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai

how to call single code multiple times? Empty Re: how to call single code multiple times?

Fri Apr 19, 2013 6:53 pm
it works perfectly... thanks much


but what should i do if i want to change that
storeEval | prompt("Enter the index") | index to
storeEval | confirm ("Enter the index") | index


and if i click yes can perform the loop but if i want to cancel the steps how can i do .. right now the script goes continuously ...
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO

how to call single code multiple times? Empty Re: how to call single code multiple times?

Tue Apr 23, 2013 5:16 am
Why not just stop the script? That seems like a lot of unnecessary effort and user interaction to get the same result.
Sponsored content

how to call single code multiple times? Empty Re: how to call single code multiple times?

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