How to resolve InvalidSelectorException in Selenium

Selenium allows users to extract a particular element from within the webpage using selectors. The InvalidSelectorException or the org.openqa.selenium.InvalidSelectorException: invalid selector error occurs when the XPATH added is not valid.

svg viewer

Solution

  • Recheck the punctuations such as @, ', and [].
  • Ensure that there is only one field name with that path; else, use the contains() method.
Copyright ©2024 Educative, Inc. All rights reserved