Write Dynamic CSS Selector in Selenium using multiple ways

Selenium supports 8 locators, please check below screenshot.

Symbol used while writing CSS selector in Selenium Webdriver

Different ways to write CSS selector in Selenium to identify Dynamic elements

1. Find CSS Selector using Single Attribute

2. Find CSS using Multiple attributes.

3. Find CSS using id and Class name

The class name generally will not be unique so always try class name with some other attributes.

4. Find CSS using contains

In CSS we will use * symbol to check particular attribute contains that value or not

In below example, it will partially check if link title contains “Password lost ” if yes then it will match.

I have taken the only link in this example but you can take any tag and any attribute.

5. Find CSS using Start-with

In below example, I have taken the only link but you can take any element.

6. Find CSS using ends-with

Now you must be having a clear picture in mind for CSS Selector in Selenium and I would recommend trying all technique at least once using same or some other applications.

Click link CSS Selector Part 2 CSS Selector Part 2

Check link for Dynamic XPath

Please give your suggestions at online.nimit@gmail.com

How to write Dynamic XPath in Selenium

1. Using Single Attribute

2. Using Multiple Attribute

3. Using contains method

4. Using starts-with method

5. Using Following node

6. Using preceding node

Check for Dynamic CSS locators

Please share your feedback at online.nimit@gmail.com as well.