TestProject Forum

Test Recorder change default selectors

When i click for example a input field in the test recorder there are 4 selectors created automatically:

  • CSS item ID
  • CSS item Name
  • 2 different XPath selectors

I want to achieve that when i click a inputfield in the test recorder, that instead 2 CSS selectors (item ID and item Name), a CSS selector with specific CSS classes will be added (programmatically). Can i write for example an Addon that will create specific CSS selectors on an “Element creation” via the test recorder? Or are there other ways to achieve this?

Best regards

Hello @maurice.rossi,

The default behavior of the agent is to add the best possible locators for the element that you are interacting with, if you want to override this behavior and give priority to other locators you could do this by navigating to the applications tab in the web platform:

Choose the application that you want to change the locator priority for, and click on this icon:

Then you can add a new Custom Attribute Strategy, and change the order of the existing locator strategies.


Thank you @artem.kuznetsov

I think i will get it working with this.

But just for interest, can you also tell me if it’s possible to create this selectors in the test recorder programmatically?

Let’s say i want to check which CSS classes the clicked element has and only add a selector that contains some CSS classes that are following a specific pattern.

Best regards

Hello @maurice.rossi,

There isn’t an option to change an elements locator programmatically,
But what you could do is to create an addon that gets as input the element,
check it’s locators and then output a string with a specific built locator that you want,
and then you can change the locator of an element to be this string using parameters:


Ok thanks for the feedback!