- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 6:32 am
Hi,
Is it possible to click (ClickAt) on an area of the webpage using only the coordinates (without an element name in the Target field)?
I have to click on two datepickers and they both have the same class name. The ID's are dynamically generated, so I can't use them. There is no other useful way to identify them.
I am using Selenium IDE.
Thanks.
Is it possible to click (ClickAt) on an area of the webpage using only the coordinates (without an element name in the Target field)?
I have to click on two datepickers and they both have the same class name. The ID's are dynamically generated, so I can't use them. There is no other useful way to identify them.
I am using Selenium IDE.
Thanks.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 10:18 pm
Have you tried using the element's XPath?
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 10:46 pm
Yes, I have tried xpath. But the problem is that the two date-picker controls are dynamically generated and the xpath and ID change each time the form loads. If there is a way to grab either the xpath or the ID after the page loads, then that would work. But so far nothing works. Coordinates are a good possibility but Selenium IDE seems to want an element identifier of some sort to go along with the coordinates. There is no static element identifier. When I tried using a class name, the coordinates are ignored and it only works for one of the two date-pickers (the first one found).
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 11:15 pm
How are you using your XPath? If your XPath locator has that dynamic ID in there it won't work for obvious reasons, for instance //div[@id='465135131315'] the first time //div[@id='487643585'] the second. Would it be possible to include a snippet of code for me to look at?
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 11:45 pm
The code is below.
Only one of the date-pickers shows up when I inspect the date-picker controls.
I have to do an inspect for each to get the code below.
The two date-picker controls are in bold.
They are the typical type where you click on them and a drop-down appears with the days of the current month. I am able to get to the days using "link=[day]" ex: link=14
Thanks.
== This is the first date-picker (FromDate) ===
== This is the second date-picker (ToDate) ===
Only one of the date-pickers shows up when I inspect the date-picker controls.
I have to do an inspect for each to get the code below.
The two date-picker controls are in bold.
They are the typical type where you click on them and a drop-down appears with the days of the current month. I am able to get to the days using "link=[day]" ex: link=14
Thanks.
== This is the first date-picker (FromDate) ===
== This is the second date-picker (ToDate) ===
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 11:54 pm
It seems I need to remove the opening and closing brackets for the code to show.
FromDate:
input id="dp1377707064118" class="calIcon hasDatepicker" type="text" readonly="false" dataname="FromDate
ToDate:
input id="dp1377707064119" class="calIcon hasDatepicker" type="text" readonly="false" dataname="ToDate"
FromDate:
input id="dp1377707064118" class="calIcon hasDatepicker" type="text" readonly="false" dataname="FromDate
ToDate:
input id="dp1377707064119" class="calIcon hasDatepicker" type="text" readonly="false" dataname="ToDate"
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Wed Aug 28, 2013 11:55 pm
Here's what the xpath looks like for the first date-picker:
//*[@id='dp1377707064118']
//*[@id='dp1377707064118']
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Thu Aug 29, 2013 12:01 am
Each time the page loads, my automation clicks on the "Clear Fields" button first to clear the old input. This will cause the date-picker controls' ID to change. I have to do this each time in order to test.
The xpath changes each time as well, although the control's position remains static on the page. Which is why I want to use coordinates.
The xpath changes each time as well, although the control's position remains static on the page. Which is why I want to use coordinates.
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO
Re: ClickAtAndWait using only coordinates (no element info)
Thu Aug 29, 2013 12:16 am
This may confusing, but bear with me. You can change the XPath to start at one of the other IDs in the DOM. This way you won't even need the ID of these fields bc it will go directly to the location. I steer away from using coordinates, bc they seem to be very unreliable.
Hit F12 and copy the code on the page from the last ID before you get to these all the way down until the To Date field. I can then walk you through rewriting the XPath.
It looks like the To Date is +1 number dynamically generated, so if you can also store that you can store that ID for the From Date you can get the To Date ID as well.
Hit F12 and copy the code on the page from the last ID before you get to these all the way down until the To Date field. I can then walk you through rewriting the XPath.
It looks like the To Date is +1 number dynamically generated, so if you can also store that you can store that ID for the From Date you can get the To Date ID as well.
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Thu Aug 29, 2013 1:06 am
Yes, I see what you're getting at. If I can somehow grab the ID of the first date-picker, then I can increment the last digit to locate the second date-picker.
There seems to be some consistency to the ID's generated. They all start with "dp13777".
Below is an example of reloading the page three times and hitting the "Clear Fields" button.
I need some way to find and extract the ID or xpath from the page and then I can store it in a variable and use it for both date-pickers. I know there is a "Contains" method but I haven't been able to get it to work properly. Any ideas?
Thanks again.
xpath: //*[@id='dp1377712101556']
ID: "dp1377712101556"
xpath: //*[@id='dp1377712214634']
ID: "dp1377712214634"
xpath: //*[@id='dp1377712348144']
ID: "dp1377712348144"
There seems to be some consistency to the ID's generated. They all start with "dp13777".
Below is an example of reloading the page three times and hitting the "Clear Fields" button.
I need some way to find and extract the ID or xpath from the page and then I can store it in a variable and use it for both date-pickers. I know there is a "Contains" method but I haven't been able to get it to work properly. Any ideas?
Thanks again.
xpath: //*[@id='dp1377712101556']
ID: "dp1377712101556"
xpath: //*[@id='dp1377712214634']
ID: "dp1377712214634"
xpath: //*[@id='dp1377712348144']
ID: "dp1377712348144"
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO
Re: ClickAtAndWait using only coordinates (no element info)
Thu Aug 29, 2013 5:00 am
What I need is the last ID in the DOM before these date pickers. If you copy and paste the code from the page with the date pickers and the code above that I can walk you through setting up the XPath. This way you don't even need the IDs for the 2 date pickers
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Thu Aug 29, 2013 11:29 pm
Below is the code just above the date picker.
I've included code with two ID's. Hope this is what you needed.
Thanks.
Code above date picker:
div class="div-searchPanel-style"
div id="PickUpDiv" class="div-searchPanel-style"
div class="searchPanelPickUp"
div>
a id="btnShowHideDate" class="a-icon a-icon-collapse" href="#"
label class="collapsablePanelHd">Date range
div class="datePanel">
div class="dateRow">
label>From
Date Picker:
input id="dp1377793264391" class="calIcon hasDatepicker" type="text" readonly="false" dataname="FromDate"/>
I've included code with two ID's. Hope this is what you needed.
Thanks.
Code above date picker:
div class="div-searchPanel-style"
div id="PickUpDiv" class="div-searchPanel-style"
div class="searchPanelPickUp"
div>
a id="btnShowHideDate" class="a-icon a-icon-collapse" href="#"
label class="collapsablePanelHd">Date range
div class="datePanel">
div class="dateRow">
label>From
Date Picker:
input id="dp1377793264391" class="calIcon hasDatepicker" type="text" readonly="false" dataname="FromDate"/>
- ccoxMaster
- Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO
Re: ClickAtAndWait using only coordinates (no element info)
Fri Aug 30, 2013 5:13 am
//div[@id='PickUpDiv']/div/a/label/div[2]/input
Basically work your way down through the DOM in sort of a hierarchy. It is difficult to tell how this is formatted from the way it is pasted. It should be easy to tell how I'm setting up the XPath from the code you gave me though. If this doesn't work, try taking a screenshot of the code and attaching it. Or just keep playing with the XPath until you get it right.
An easy way to test if it finds it is to enter the XPath in the locator field and click the find button. If it highlights on the page, it finds it. If it give you an error that it couldn't find it, change the XPath.
Hopefully this helps!
Basically work your way down through the DOM in sort of a hierarchy. It is difficult to tell how this is formatted from the way it is pasted. It should be easy to tell how I'm setting up the XPath from the code you gave me though. If this doesn't work, try taking a screenshot of the code and attaching it. Or just keep playing with the XPath until you get it right.
An easy way to test if it finds it is to enter the XPath in the locator field and click the find button. If it highlights on the page, it finds it. If it give you an error that it couldn't find it, change the XPath.
Hopefully this helps!
- kevinklk42Active particpant
- Posts : 11
Join date : 2013-08-28
Re: ClickAtAndWait using only coordinates (no element info)
Fri Aug 30, 2013 7:01 am
There seems to be an issue attaching a simple gif to this post (I tried several times).
Here is the first ID that is above the date picker element:
id=btnShowHideDate (xpath: //*[@id='btnShowHideDate'])
Could you please give me an example of how I would find the first element (btnShowHideDate) and then work my way down? Does it require a loop (I've been using the Sel Blocks add-on)?
Thanks again.
Here is the first ID that is above the date picker element:
id=btnShowHideDate (xpath: //*[@id='btnShowHideDate'])
Could you please give me an example of how I would find the first element (btnShowHideDate) and then work my way down? Does it require a loop (I've been using the Sel Blocks add-on)?
Thanks again.
Permissions in this forum:
You cannot reply to topics in this forum