Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Regarding Alert Interface
Fri Feb 24, 2017 2:00 pm by karthikeyakumar

» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

how to call single code multiple times?

View previous topic View next topic Go down

how to call single code multiple times?

Post by anbarasi on 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 ...

anbarasi
Amateur
Amateur

Posts : 45
Join date : 2012-04-30
Age : 29
Location : chennai

Back to top Go down

Re: how to call single code multiple times?

Post by ccox on 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

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: how to call single code multiple times?

Post by anbarasi on 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

anbarasi
Amateur
Amateur

Posts : 45
Join date : 2012-04-30
Age : 29
Location : chennai

Back to top Go down

Re: how to call single code multiple times?

Post by anbarasi on Mon Apr 15, 2013 6:41 pm

need to change that store |1|i command , like to store 2 then 3 etc..

anbarasi
Amateur
Amateur

Posts : 45
Join date : 2012-04-30
Age : 29
Location : chennai

Back to top Go down

Re: how to call single code multiple times?

Post by ccox on 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.

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: how to call single code multiple times?

Post by anbarasi on 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.

anbarasi
Amateur
Amateur

Posts : 45
Join date : 2012-04-30
Age : 29
Location : chennai

Back to top Go down

Re: how to call single code multiple times?

Post by ccox on 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

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: how to call single code multiple times?

Post by anbarasi on 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 ...

anbarasi
Amateur
Amateur

Posts : 45
Join date : 2012-04-30
Age : 29
Location : chennai

Back to top Go down

Re: how to call single code multiple times?

Post by ccox on 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.

ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: how to call single code multiple times?

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

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