TestProject Forum
Powered by leading experts in the test automation community

Use locators other then Xpath

In the readme for the C# demo tests and addons:

“Element Actions are made to be used on a specific Element Types. Element Types are defined in TestProject using XPath to describe target elements similarities:”

Are there plans to make elements selectable by, for example, id or linktext?

Hi @snelzing,

It’s not accurate. Can you please share with me the exact link where you read it?
Anyway, an element in TestProject can be located using any locator strategy that you want (e.g. id, XPath, name, etc.).

Whether it’s a recorded or coded test, you can use any locator strategy that you want to locate the element (as long as this element contains this attribute).

In the recorder, for example, we have an algorithm that selects the best available locator (starting from id and all the way to absolute XPath in case that there are no other unique options).

You can even create your own custom element by combining parameters and other attributes as described here: https://intercom.help/testprojectio/en/articles/3572023-how-to-create-custom-xpath-with-text-label-class-etc

Let me know if you’ll need help with that :slight_smile:

Kind regards,
Amit

1 Like

Sure, here are the two places it is mentioned:

https://docs.testproject.io/testproject-sdk/c-sdk

That is good to know about the algorithm. Thanks :slight_smile:

Hi @snelzing,

Thank you for sharing this link with me :slight_smile:
It might be confusing, but what this paragraph says is that we identifying the elements type using XPath. It’s not an instance of a specific element, but its type.
For example, a button element in web test can be: , , etc. We define all the standards elements that qualify this type.

Hope this make sense :slight_smile:
Anyway, you should know that you can create/locate element with any locator strategy that you want.

Kind regards,
Amit

1 Like