What is CSS in Selenium

Element found in selenium from css

Just using class names is not enough in your case.

  • has 15 matching nodes
  • has 11 matching nodes
  • has 5 matching nodes

Hence, you need more constraints to narrow it down. Options 1 and 2 below are available for the CSS selector. Perhaps 1 is the one that best suits your needs.

Option 1: Use the index of the list elements (CssSelector or XPath)

restrictions

  • Not stable enough when the structure of the site changes

Example:

Option 2: use from Selenium, then index. (CssSelector or XPath)

restrictions

  • Not stable enough when the structure of the site changes
  • Not the native voter's route

Example:

Option 3: use text (XPath only)

restrictions

  • Not for multilingual websites
  • Only for XPath, not for Selenium CssSelector

Example:

Option 4: index the grouped selector (XPath only)

restrictions

  • Not stable enough when the structure of the site changes
  • Only for XPath, not for CssSelector

Example:

Option 5: Find the link to the hidden list items after href and then go back to h5 (XPath only)

restrictions

  • Only for XPath, not for CssSelector
  • Bad performance
  • Tricky XPath

Example: