locate an element that is changing its ID and xpath everytime

1,833 views
Skip to first unread message

supriya

unread,
Mar 19, 2012, 2:24:13 AM3/19/12
to Selenium Users
HOW to locate an element who's ID and xpath is changing continuously?

Go to the site www.ibibo.com
Do click the image "login with fb Id" on the rigth hand side and type
the facebook id and password to the popup window and do click the
"login" botton which is located at the bottom layer of that popup
window.
when i m recording all this uding IDE , Every time the ID of dat Login
button is getting change.
Please tell me how to handle such type of elements..?
Thanks
Supriya Singla

Vishal Mishra

unread,
Mar 19, 2012, 2:28:21 AM3/19/12
to seleniu...@googlegroups.com
Try DOM or JS locators in this case.

supriya singla

unread,
Mar 19, 2012, 3:18:20 AM3/19/12
to seleniu...@googlegroups.com
DOM works in Web driver also?
Thanks
Supriya Singla

On Mon, Mar 19, 2012 at 11:58 AM, Vishal Mishra <vishal....@gmail.com> wrote:
Try DOM or JS locators in this case.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

jeevan

unread,
Mar 19, 2012, 3:26:47 AM3/19/12
to seleniu...@googlegroups.com
Hi,
One thing u can use name=login which is not changing. And second thing with the ID the first two characters of the ID is same..so we can play with this..like use xpath with contains..

//input[contains(text(),'somevalue')].....



Thanks,
Jeevan.



On Mon, Mar 19, 2012 at 11:58 AM, Vishal Mishra <vishal....@gmail.com> wrote:
Try DOM or JS locators in this case.

supriya singla

unread,
Mar 19, 2012, 4:39:26 AM3/19/12
to seleniu...@googlegroups.com
Thank you so much. Now its working. But the second option i m not getting.
Yes first 2 characters are same.
But how to play with them?

jeevan

unread,
Mar 19, 2012, 5:25:07 AM3/19/12
to seleniu...@googlegroups.com
:) well...u can play with xpath contains like..

//input[contains(text(),'somevalue')].
//input....this can be changed to     
 - > a
 - > link
 - > table
 etc...followed by [contains(text(),'here u can give the part of the element if it changes frequently')]
else u can use :
1. ID
2.Name
3. Link
4.ClassName
5.CssSelector
6.finally xpath.....dont use xpath directly...even for dynamically changing objects we can find the value tag or classname or title or alt.
If u not able to find then go for Xpath.

Thanks,
Jeevan

supriya singla

unread,
Mar 19, 2012, 5:37:02 AM3/19/12
to seleniu...@googlegroups.com
Ok. Thanks a lot Jeevan.:)

Javed Chowdry

unread,
Jan 23, 2015, 12:00:41 PM1/23/15
to seleniu...@googlegroups.com
I have this xpath ""//*[@id='deleteLogoLink750533']"

After deleteLogoLink the numbers constantly change. can someone please advise how can i create customize xpath for this. This is link xpath though. please help
Reply all
Reply to author
Forward
0 new messages