Hi, I am trying to capture the dynamic id, but am unsuccessful as it keeps changing
Order Number #1700090
(upload://yo3LiFDM4S2CS1niMyHL3kfaUcr.png)
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):
id("trSuccessful")/div[2]/div[2]/div[2]/div[1]/span
In your target HTML, do you find any <iframe>
element?
If yes, you need to switch the context into the Frame using
https://docs.katalon.com/katalon-studio/docs/webui-switch-to-frame.html
Thank you. There is no iframe element in the HTML.
1 Like
@sasharay4
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.
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:
WebUI.click(findTestObject('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:
WebUI.click(findTestObject('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')
Rational:
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.