Xpath ID is changing how to set up dynamically

The folloing expression is too long; therefore error-prone and difficult to maintain.

//*[starts-with(@id,'id-a837e4a7-01b8-4f82-a475-be9abd67e667-')][substring(@id, string-length(@id) - string-length('-name-name.fieldControl-text-box-text') +1) = '-name-name.fieldControl-text-box-text']

You would want to parameterize the expression like this:

//*[starts-with(@id,'${PREFIX}')][substring(@id, string-length(@id) - string-length('${POSTFIX}') +1) = '${POSTFIX}']

The following post would tell you how to make a parameterised Test Object in Katalon Studio

1 Like