Sobes.tech
Middle+

How would you find an element locator? Would you be able to add an ID to the application yourself?

sobes.tech AI

Answer from AI

To find an element locator on a page, developers usually use browser developer tools (DevTools). There, you can:

  • Hover over an element to see its HTML.
  • Identify unique attributes: id, class, name, data-*.
  • Create a CSS selector or XPath that uniquely identifies the element.

For example, if an element has a unique id, the locator will be #elementId (CSS) or //*[@id='elementId'] (XPath).

If the application does not have unique identifiers, you can suggest adding an id attribute or data-test-id specifically for testing. This will improve the stability and readability of tests.

Adding an ID to the application usually requires access to the source code and coordination with developers. In a simple case, it might look like this:

<button id="submitBtn">Send</button>

Thus, the locator becomes simple and reliable.

How would you find an element locator? Would you be… - sobes.tech