Cannot capture dynamic id and verify match

Hi, I am trying to capture the dynamic id, but am unsuccessful as it keeps changing
Order Number #1700090

Also I am trying to verify match on
Page 1 -Order Number #1700091
Page 2- Order Number: 1700091

Thanks for looking

Edit the the XPath of your Test Object to be

//span[starts-with(text(), 'Order Number']

Thank you, but I get this error=============== ROOT CAUSE =====================
Caused by: com.kms.katalon.core.exception.StepFailedException: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Gift OR/Order no displayed on order confirmed’ located by ‘//span[starts-with(text(), ‘Order Number’]’ not found

What @kazurayam gave you should have worked for an element that had the text, Order Number, for it. I noticed the element in your error message is, “Order no displayed on order…” . Does this mean that the Order number is not displayed for this element at this time?

Also, the “dynamic id” you are trying to capture (from the heading of your post), is it the Order Number id?

hmmm. You could try the following xpath for the element used in the picture above (although it is quite a distant starting point):


In your target HTML, do you find any <iframe> element?

If yes, you need to switch the context into the Frame using

Thank you. There is no iframe element in the HTML.

1 Like


I guess that you have a timing problem. I guess that you script is trying to find a text “Order Number xxxx” before the the text becomes visible on the page.

In order to get better idea, please share your Test Case script.

1 Like

In the statement that you have underlined, is there an extra apostrophe in front of “Order Number”?

Thank you.That was great attention to detail. That was a copy and paste error… The orginal code has WebUI.verifyElementText(findTestObject(‘Gift OR/Order no displayed on order confirmed’), ‘Order Number’)

Current code:'Object Repository/Gift OR/Page_Online Ordering/button_PLACE MY ORDER'))
WebUI.verifyElementText(findTestObject('Gift OR/Order no displayed on order confirmed'), 'Order Number')

Please change it to:'Object Repository/Gift OR/Page_Online Ordering/button_PLACE MY ORDER'))

WebUI.waitForElementPresent(findTestObject(‘Gift OR/Order no displayed on order confirmed’), 10)

WebUI.verifyElementText(findTestObject(‘Gift OR/Order no displayed on order confirmed’), 'Order Number')


When you click the “PLACE MY ORDER” button, your web page will be redrawn — a new URL could be loaded, or JavaScript ran to redraw the page — which will take a while (a few seconds or micro seconds). Your code NEED TO WAIT for the new page view to come up.

However your original script calls
WebUI.verifyElementText soon after clicking the button. The verifyElementText keyword DOES NOT WAIT until the target to be visible. Therefore the verifyElementText fails to find the ‘Order Number’ text, because the text ‘Order Number’ is not yet visible at the time when your script called verifyElementText.

In order to fix it, your code should explicitly WAIT for the element before accessing its text content.

Thank you so much. This worked perfectly.