Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

how to store csscount/xpath count in a variable and increment it?

View previous topic View next topic Go down

how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Thu Aug 29, 2013 11:49 pm

Code:
<td class="datepickerSelected"> 
<a href="#"> 
<span>21</span> 
</a> 
</td> 
 <td class=""> 
<a href="#">

This is my code.
what is the csscount/xpath count?
 I want to store it in a variable. And selenium should click on the stored link on satisfying a conditon.
Then the count should be incremented(to point the next xpath location).
Selenium should click on the new link.
 Please help on this.
 Thanks in advance.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Thu Oct 24, 2013 3:52 pm

Firstly you need to store total links you need to visit.


storeXpathCount | //a/@href | totalhref


Then with the help of while loop, you can click on every link.


store | 0 | x

while | storedVars['x']

storeEval | window.document.getElementsByTagName('a').item(${x}).href | href${x}

getEval | storedVars['x']=${x}+1

endWhile



With the above code, you will be able to store all links.


With the below code, you will be able to visit each stored link.


store | 0 | y

while | storedVars['y']

storeEval | storedVars['href${y}'] | link

open | ${link}

verifyLocation | ${link}

getEval | storedVars['y']=${y}+1

endWhile

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Thu Oct 24, 2013 4:02 pm

Thank you very much for help. I will try this.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Thu Oct 24, 2013 4:04 pm

Code:
I used storeXPathCount to get the set of links matching a specific format. Lets consider the count would be 12. So there are 12 different links available which will have different dates like 20, 21, 22,.....31. I want to store these values of the links in an array and use the values one by one.

Getting the first value from array(i.e. 20).
Check for condition.
If condition fails, increment the array count by 1.(It should be 21).
Again check for condition and increment the array.


This is what I am exactly looking for.
Any update on this would be helpful.


sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Thu Oct 24, 2013 4:16 pm

You need to identify value of span. With link of href, you need to store value of span in other variable.

If you can paste exact code or portion of code, that will be helpful.

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Thu Oct 24, 2013 4:45 pm


    open
    http://46.staging-cochii-hrd.appspot.com/bookanappointmentv3.do?uniqueKey=8a37ea79-c5b2-4c36-9180-3ec293474aa8
   


    store
    No Slots Available
    v1


    label
    START
   


    waitForElementPresent
    css=b
   


    click
    css=b
   


    waitForElementPresent
    //div[4]/ul/li/div/b
   


    click
    //div[4]/ul/li/div/b
   


    waitForElementPresent
    css=td.datepickerSelected > a > span
   


    click
    css=td.datepickerSelected > a > span
   


    storeXpathCount
    //div[@class='datepicker']/div/table/tbody/tr/td/table/tbody[2]/tr/td[@class=''   or @class='datepickerSaturday' or @class='datepickerSunday']
    count


    echo
    ${count}
   


    storeEval
    ${count}
    array


    getEval
    index = 0;
   


    while
    index < storedVars['count']
   


    storeText
    //div[@class='datepicker']/div/table/tbody/tr/td/table/tbody[2]/tr/td[@class='' or @class='datepickerSaturday' or @class='datepickerSunday']/a/span[contains(text(), "")]
    value


    echo
    ${value}
   


    click
    //div[@class='datepicker']/div/table/tbody/tr/td/table/tbody[2]/tr/td[@class='' or @class='datepickerSaturday' or @class='datepickerSunday']/a/span[contains(text(), "${value}")]
   


    verifyText
    css=div.time_sheet
   


    storeText
    css=div.time_sheet
    i


    echo
    ${i}
   


    gotoLabel
    storedVars['i'] == storedVars['v1']
    INC


    waitForElementPresent
    //div[4]/ul/li[2]/a
   


    click
    //div[4]/ul/li[2]/a
   


    type
    id=first_name
    test


    type
    id=phone_num
    35252


    click
    id=customer_details
   


    click
    css=#message_remainder_check
   


    click
    css=span.global_btn2_rt
   


    gotoLabel
    START
   


    label
    INC
   


    getEval
    index++;
   


    endWhile
   
   


Last edited by sathiyarengarajan on Thu Oct 24, 2013 6:10 pm; edited 1 time in total

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Thu Oct 24, 2013 4:59 pm

I am using this format to get the total no of links available.

//div[@class='datepicker']/div/table/tbody/tr/td/table/tbody[2]/tr/td[@class=''   or @class='datepickerSaturday' or @class='datepickerSunday']

Consider total links count would be 12.
I want the values present in these 12 links to be stored in an array.
I should get the first link value(ex:21).

I should click the link containing 21.

//div[@class='datepicker']/div/table/tbody/tr/td/table/tbody[2]/tr/td[@class='' or @class='datepickerSaturday' or @class='datepickerSunday']/aspan[contains(text(), "${value}")]

Check for a certain condition. If condition fails, array should be incremented to point the next array item.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Fri Oct 25, 2013 12:06 pm

Sorry to say this but i asked you for page code. I mean the code portion you want to fetch links and all.. I need to look into that code. Atleast code from VIEW SOURCE.

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Fri Oct 25, 2013 10:04 pm

http://46.staging-cochii-hrd.appspot.com/bookanappointmentv3.do?uniqueKey=8a37ea79-c5b2-4c36-9180-3ec293474aa8


This is the URL

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Wed Oct 30, 2013 6:01 pm

Hi, Sorry for late reply.

Below is your complete case to store all time slots available today for all staffs and all services.

openhttp://46.staging-cochii-hrd.appspot.com/bookanappointmentv3.do?uniqueKey=8a37ea79-c5b2-4c36-9180-3ec293474aa8
storeXpathCount//li/@onclicktotalServices
store1m
whilestoredVars['m'] <= storedVars['totalServices']
clickAt//ul//li[contains(.,"Service${m}")]
pause3000
storeXpathCount//li/@onclicktotalStaff
store1n
whilestoredVars['n'] <= storedVars['totalStaff']
storeElementPresent//ul//li[contains(.,"Staff${n}")]presents
gotoIfpresents == ""endcase
clickAt//ul//li[contains(.,"Staff${n}")]
pause3000
store1x
while${x}<4
if${x} == 1
store50z
endIf
if${x} == 2
store18z
endIf
if${x} == 3
store29z
endIf
if${x} == 1
storeMorningtimeslot
endIf
if${x} == 2
storeAfternoontimeslot
endIf
if${x} == 3
storeEveningtimeslot
endIf
storeEval2y
while${y} < ${z}
storeEval${y} - 1time
storeElementPresentxpath=id('timesheet')/ul[${x}]/li[${y}]/apresent
gotoIfpresent == ""endinnerloop
storeTextxpath=id('timesheet')/ul[${x}]/li[${y}]/aService ${m} - Staff${n} - Time Slot - ${timeslot} - ${time}
labelendinnerloop
storeEval${y} + 1y
endWhile
storeEval${x} + 1x
endWhile
labelendcase
clickAtxpath=id('gt_act')/div[1]/ul/li[3]/span
pause2000
storeEval${n} + 1n
endWhile
clickAtxpath=id('gt_act')/div[1]/ul/li[1]/span
pause2000
storeEval${m} + 1m
endWhile

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Wed Oct 30, 2013 8:00 pm

Hi,
Thank you so much for your reply.
I tried to execute the code which you provided.
I am getting the following error on executing the code
[ltr]gotoIf[/ltr][ltr]present == ""[/ltr][ltr]endinnerloop[/ltr]
[error] Unexpected Exception: ReferenceError: presents is not defined. fileName -> chrome://flowcontrol/content/extensions/goto-sel-ide.js?1383058567164, lineNumber -> 129, columnNumber -> 0

Any help on this would be very helpful.
Thanks.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Thu Oct 31, 2013 10:41 am

Please compare your running code with code i have given here. There would be some change.Statement you have shown is having "present" and error shows "presents". So please compare once.

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Wed Nov 06, 2013 8:21 pm

Sorry to bother.
In your code one place you used presents and this is the code

StoreElementPresent  //ul//li[contains(.,"Staff${n}")]  presents
gotoIf presents == "" endcase

And other place you used present and this is the code
2.StoreElementPresent  xpath=id('timesheet')/ul[${x}]/li[${y}]/a present

Not sure what went wrong. When I execute the code it throws error as
[error] Unexpected Exception: ReferenceError: presents is not defined. fileName -> chrome://flowcontrol/content/extensions/goto-sel-ide.js?1383058567164, lineNumber -> 129, columnNumber -> 0

I am getting the above error while executing the following line:
gotoIf presents == "" endcase.

Can you explain how the above line of code works.

Thanks for your help.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by kashyap_guru on Sat Nov 09, 2013 11:31 am

May be that element is not loaded when that command is fired. Try WAITFORELEMENTPRESENT or PAUSE command. May that work.

kashyap_guru
Active particpant
Active particpant

Posts : 24
Join date : 2013-10-16
Age : 29
Location : India

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by sathiyarengarajan on Mon Feb 10, 2014 11:19 pm

Anyway, thanks for the help.
I couldnot execute the above case. But I found a solution to my problem. I stored the current date in a variable. I booked all the slots for the current date.Then I incremented the date value to book appointments for the next date. Using while loop I checked for the condition whether the date is less than or equal to 31. At the end of the loop, I incremented the date value. So I can book appointments for the entire month starting from the current date.

sathiyarengarajan
Active particpant
Active particpant

Posts : 20
Join date : 2013-08-08

Back to top Go down

Re: how to store csscount/xpath count in a variable and increment it?

Post by Sponsored content Today at 8:11 am


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