UI testing tip: clicking element by its text content

Recent Usetrace feature lets you locate an element by its text content.

Many websites and apps have user-generated content and therefore automating testing for them can be challenging. Often only the content of an element is known at the time of test definition (while the element position can be unknown).

Recent Usetrace feature lets you locate an element by its text content – there’s no need to know even the element’s type, if its text matches, Usetrace will find it.

Finding element by text

Text locators are automatically extracted and included in step’s locators when recording a trace. If you expand a step’s locators, there’re two new locator types “text equals” and “text contains”. The latter is useful when you don’t know the exact text value but only a part of it.

Text locators work not only with regular elements (lists, tables, divs, buttons, paragraphs…) but also with form placeholders.

Text locators work seamlessly together with variables and Javascript steps. You may use #{variable} syntax inside text locators to locate text that is known only in runtime.

To try it now by signing up to Usetrace.

Subscribe to our mailing list

* indicates required

Leave a Reply

Your email address will not be published. Required fields are marked *