Verify element text reading text from different element

Hi all,
I am experiencing an error that has my head scratching.

I have written an xpath for the coder list element in the menu:
//*[@id=“CL”]/span[contains(text(),“Coder List”)]

and the following step in the test script:
image

Yet I’m getting the following error:
Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text ‘Coding Outstanding’ and expected text ‘Coder List’ of test object ‘Object Repository/02 1 Coder list page load test/Top Nav - Episodes - Coder List - Span text’ are NOT matched.

It is somehow reading the “Coding Outstanding” element in the initial screenshot. When I instruct the script to click on that xpath, it does so correctly just the verify element text is doing this bizarre interaction.

Any assistance in understanding what is going on here would be much appreciated.

Thank you.

1 Like

I just guess the dop-down menu is dynamically rendered by JavaScript so that it will take some milli-seconds for the drop-down to be loaded into the DOM.

Just before you call the Verify Element Text, you need to wait for the target HTML element is loaded into the HTML DOM.

WebUI.waitForElement(... a Test Object that points the <a id="CL">, 10 seconds)

Without appropriate wait performed, your script runs too quickly; it calls the Verify Element Text before the target HTML element to be present in the DOM, so your script fails.

Found the solution - apparently I was just missing the tick box for “Detect object by?” Not sure how this actually changes it but seems to have fixed the issue :slight_smile:
image