- anbarasiAmateur
- Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai
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 ...
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 ...
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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
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
- anbarasiAmateur
- Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai
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
plz help
- anbarasiAmateur
- Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai
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..
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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.
- anbarasiAmateur
- Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai
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.
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.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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
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
- anbarasiAmateur
- Posts : 49
Join date : 2012-04-30
Age : 36
Location : chennai
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 ...
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 ...
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 39
Location : Denver, CO
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.
- Multiple tabs opening using single browser
- got "(firefox:6641):GLib-WARNING **: g_set_prgname() called multiple times" and Test Error
- For every change in the code of selenium RC, Is that necesary to compile the selenium RC code every time.
- Opne page n times
- In Nunit when my script clicks log in it times out, help please?
Permissions in this forum:
You cannot reply to topics in this forum