0

I am trying to get a list of all the selectors of a specific element using Selenium for Java.

What I want is to find a way to get all the possible selectors that the element has and save them in a list so I can call them later on and use them.

I searched for an answer but couldn't find a way to get all the selectors of a specific element.

MoominPapa
  • 11
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 21 '23 at 09:10
  • For element with more attributes there will be immeasurably many selectors/locators. A dynamic xpath can combine attribute values even with `startswith`, `endswith`, `contains` and all of them can be used with `not`. You can create any conceivable condition for your xpath that still fit to one specific element. Amount of all conceivable selectors is infinite. – pburgr Feb 21 '23 at 09:34
  • if we assume that I have an input field and I want to get all of the different selectors (css, xpath, id, etc) is there a way that I can perform that programmatically? – MoominPapa Feb 21 '23 at 09:43
  • Yes but on page can be more elements with same id, name, class. You have to take that into account to avoid more elements matching one locator. – pburgr Feb 21 '23 at 10:14
  • You can use a extension like Selectors HUB it will show all possible locators of an element – Abhay Chaudhary Mar 30 '23 at 10:48

0 Answers0