Can we use normal locators to automate Pseudo-Elements in Selenium?

Can we use normal locators to automate Pseudo-Elements in Selenium?

Hi Mark,

Pseudo-elements are special elements, which you cannot work with using normal Selenium locators. Since the pseudo-elements in CSS aren’t static HTML elements, they are created on the fly when they need to be viewed. This is why they are executed in the front end at runtime and “live” only when the page loads. When the Selenium WebDriver wants to interact with these pseudo-elements, the code gives NoSuchElementError.

However, pseudo-elements can be automated in Selenium with the help of JavaScriptExecutor.

To know how to work with Pseudo-Elements in Selenium JavaScript, please go through the following blog:

1 Like