How to Select a Web Element With an ID Containing '.'
Want to know how to select a web element with an id containing '.' ? Well, you're in luck... Alan Richardson provides a quick fix for this.
Join the DZone community and get the full member experience.Join For Free
i was working with a site and trying to select an element via its
<p id="select.me.by.id">select me by my id</p>
simples, thought me:
so, i did what all good selenium debuggers do… i tried in the browser but chrome didn’t match it.
tempted though i was to blame chrome, i tried with xpath, and that worked fine:
after a bit of web searching, the solution was clear.
in css, i wasn’t saying: find the id
i was saying find the id
which was not at all what i wanted.
fortunately, css offers escaping, which i didn’t realize.
until the app is fixed i can locate the id using css with:
Published at DZone with permission of Alan Richardson, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.