What if elements have dynamic id?

How do we record or create test case in this case?

hello,
basically you have 2 choices:
1. you need to construct such xpath/css that will identify your element in DOM (by hand) and/or
2. ask dev team to add unique identifier to elements e.g. adding attribute like QAID to interesting elements will help you

Option 1 means if postition of element changed, then test case would be invalid?

Eric said:

Option 1 means if postition of element changed, then test case would be invalid?

not necessary, you need to try to make it as resilient to change as possible:
1. make xpath as short as possible - add resilience
2. always try to find one stable element and use relative path from it

Another option (but more complex) - add the dynamic element to the identifier (eg Xpath/CSS…):
https://docs.katalon.com/katalon-studio/docs/manage-test-object.html#parameterizing-test-object

Eric,

The following article may be informative for you:

Thanks I guess that’s what I ended up doing…identifying the uniqueness of objects using xpath and combination of their attributes.

But then as the page says here https://docs.katalon.com/katalon-studio/tutorials/create_test_case_using_record_playback.html

Identifying objects this way is painful and time consuming…so I was thinking is that possible using recorder and change their default behavior / parameter? Instead grabbing object’s id I want to grab object’s name while recording…It would cut the unnecessary job.

1 Like

I was hoping something can be setup like
Project->Settings->TestDesign->WebLocators->Attributes
then you could tick/untick attributes which one to decide to identifying objects but then this has no effect I untick the id still the recorder picks the id.

Or in short how do we identifying objects by attributes and ignore/disable xpath settings?

1 Like