verifyTextPresent() - Text is not present on page

Hi guys, I’m trying to test the last step of my test case verifying the success text after clicking on continue button but the words are not being found in the page, its always on the same windows with the same URL

WebUI.click(findTestObject('Page/button_Continue'))

WebUI.verifyTextPresent('Check your inbox', false, FailureHandling.STOP_ON_FAILURE)

WebUI.closeBrowser()

Screenshoot of the page:

(I have tried with the first words of the paragraph below the title but with the same results)

Console:

2019-07-19 00:53:13.295 DEBUG testcase.2. Create a new buyer
20: click(findTestObject(“Page/button_Continue”))
2019-07-19 00:53:13.454 DEBUG testcase.2. Create a new buyer
21: verifyTextPresent(“Check your inbox”, false, STOP_ON_FAILURE)

2019-07-19 00:53:14.548 ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Text ‘Check your inbox’ is not present on page (Root cause: com.kms.katalon.core.exception.StepFailedException: Text ‘Check your inbox’ is not present on page
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.doCall(VerifyTextPresentKeyword.groovy:79)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.call(VerifyTextPresentKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83)
at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.execute(VerifyTextPresentKeyword.groovy:68)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1677)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$6.call(Unknown Source)
at 2. Create a new buyer.run(2. Create a new buyer:57)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1563508374112.run(TempTestCase1563508374112.groovy:21)

1 Like

Firstly, that’s a superb problem report - it’s not often a new user provides such detailed info. Well done!

Looking at the issue, I’m going to take a guess that there’s a delay before that text appears after you’ve clicked the button. If that’s true, try waiting for the DIV element to be visible first (there is no waitForTextPresent in the WebUI API set AFAIK).

If you still get issues, to prove this is indeed a timing issue, try a fixed delay (couple seconds should be plenty) then try to verify it’s present.

Thanks @Russ_Thomas for the acomplish

Yeap I tried the action waitForPageLoad() and set some seconds into it but still same issue. Also, I have tried the action SwitchWindowsIndex(0) cause I have another test that verify correctly the text I setup but in that case opens in other windows (is not the case here cause is on the same windows)

I will try that! I have to add DIV element as an object in my repository and then use the action WaitForElementPresent() and/or verifyForElementPresent(), right?

Try waitForElementVisible (it will also prove it is present at the same time).

https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-visible.html

waitForPageLoad is a good idea, but it doesn’t help with individual elements. The page may be loaded, but the browser still needs time to build the elements on the page. You can think of waitForPageLoad as waiting for the HTML, JavaScript and CSS to be loaded – but it does not mean the browser/page is “ready” for use.

@Russ_Thomas seems to be working great now!

I still don’t catch why I have to save that div as an element to be able to find it on the page (after I wait for more than 10 seconds to the page loads) by the way thanks for the helpmate.

This was my solution

WebUI.click(findTestObject('Page/button_Continue'))

    action=WebUI.waitForElementPresent(findTestObject('Page/email confirmation -we ve sent a message'), 3, FailureHandling.STOP_ON_FAILURE)

    System.out.println(action)

    WebUI.closeBrowser() 

I use a variable there only to be sure that the element has been found but I suppose is unnecessary using the FailureHanding

1 Like

Rodrigo

I’ve unmarked your solution because it does not provide a solution to the problem as originally stated.