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
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

Thu Oct 24, 2013 4:02 pm
Thank you very much for help. I will try this.
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.

kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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.
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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.
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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.
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

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

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.
avatar
sathiyarengarajan
Active particpant
Active particpant
Posts : 20
Join date : 2013-08-08

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

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.
Sponsored content

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

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