Skip to main content

Aug 25, 2016 - 1 minute read - FAQ Selenium Simplified Selenium Simplified Blog

How to Select a Web Element with an id containing '.'

TLDR: \.

Lesson learned.

I was working with a site and trying to select an element via its id e.g.

<p 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:

  • //p[@id='']

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 select with class me by id which was not at all what I wanted.

Fortunately CSS offers escaping, which I didn’t realise.

Until the app is fixed I can locate the id using CSS with:

  • #select\.me\.by\.id

You will need a Github account to comment. Or you can contact me with your comment.

I reserve the right to delete spam comments e.g. if your comment adds no value and its purpose is simply to create a backlink to another site offering training, or courses, etc.