Locate an element with id containing commas and apostrophes

216 views
Skip to first unread message

Always a student

unread,
Jan 5, 2018, 4:17:50 PM1/5/18
to Selenium Users

Hi Guys,

 

Thanks in advance.


I have been trying to use xpath, id and css locator for locating an element using id. The id contains commas in all elements and apostrophes also in some.

  1. Xpath passed if just commas but fails when an apostrophe is also there.
  1. Css selector doesn’t even pass with a comma
  2. When I used By.id for locating, it fails with exception 'Unable to lcoate element'. What I notice here is that it has , in runtime, added a '#' infront of the supplied string and also a '\' infront of the comma

 

So, I am stuck here. How do I locate these comma and apostrophe containing elements. Please note that id is the only unique identifier for all these element and hence, I can not use any other way. 

Srinivas P - http://testingtools.co

unread,
Jan 7, 2018, 9:52:28 PM1/7/18
to Selenium Users
I think you should give double back slash and not single backslash to escape the characters. Hope it helps. 

Thank You,
Regards,

Shray Munjal

unread,
Jan 7, 2018, 9:52:32 PM1/7/18
to Selenium Users

Always a student

unread,
Jan 9, 2018, 6:24:56 PM1/9/18
to Selenium Users
Thanks Shray.

out of all the answers at the link, what did work is the Concat solution. 

Found it explained more in detail at the below link

Reply all
Reply to author
Forward
0 new messages