Verifytextpresent action

I have a situation -

Verifytextpresent - I am searching for a text which is not present in the page and using continue on failure as failure handling
Next step i have used verifytextpresent with text present in the page.

In execution, ideally it should pass the step with text present, but it is failing. Exception says text not present. But it is taking the text of first step.

WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE) — this should fail

WebUI.verifyTextPresent(‘Statistical’, false) ---- this should pass

Hello,
why??? why not use verifyTextNotPresent …
always try to make proper conditions, imagine someone will need to repair that test after you … looking for something and ignoring non-existence makes no sense in code

to the situation - share log so we can read what’s going on there

There will be situation where search text not present but you are expecting to be present. In such case the next step should pass as well right?
Log -

02-20-2019 02:49:29 PM Test Cases/Phani3

Elapsed time: 11.875s

Test Cases/Phani3 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Text ‘phani’ is not present on page
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
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:21)
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:53)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1677)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$9.call(Unknown Source)
at Phani3.run(Phani3:36)
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:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1550692167712.run(TempTestCase1550692167712.groovy:22)

i don’t understand that test, it seems to me quite nondeterministic.

to FailureHandling.CONTINUE_ON_FAILURE you need to catch that exception to continue

try{
  WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE)
} catch (com.kms.katalon.core.exception.StepFailedException sfe){
  println "*** Text phani found, but we can continue"
}

Thanks Andrej…

Sorry if I am making no sense… I am searching for a text in the application I could not find it due to bug in the application and the step will fail which is fine… Next step should pass since it found the text right?

Again sorry for any ignorance…

yes, that’s true.
still TC will be marked as failed.

and do not apologise English is not my 1st language, so from time to time (usually) i have hard time to get things right…

Thats fine… I understand… Let the Test case fail but the step after the failed step should pass?..

This is the error message -
verifyTextPresent(“Statistical”, false) FAILED… I am searching for text “statistical” but error message says Text ‘phani’ is not present on the page which is previous step’s text.
Reason:
com.kms.katalon.core.exception.StepFailedException: Text ‘phani’ is not present on page

yes, this is true

This is not happening

please always post as much log output as you can. now is your code looking like:

try{
  WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE)
} catch (Exception e){
  println "phani on page - ignoring error"
}
WebUI.verifyTextPresent(‘Statistical’, false)

post log output… remember you are my eyes … more i see, more i can understand

This is my code -

try {
WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE)
}
catch (com.kms.katalon.core.exception.StepFailedException sfe) {
println(’*** Text phani not found, but we can continue’)
}

WebUI.verifyTextPresent(‘involves’, false) — Text present and should pass

Console log -
e[0;39m e[39m1: verifyTextPresent(“phani”, false, CONTINUE_ON_FAILURE)e[0;39m
2019-02-21 10:00:14.064 e[1;31mERRORe[0;39m e[36mc.k.k.core.keyword.internal.KeywordMain -e[0;39m e[31m❌ Text ‘phani’ is not present on page e[0;39m
2019-02-21 10:00:14.064 e[39mDEBUGe[0;39m e[36mtestcase.Phani3 -e[0;39m e[39m14: verifyTextPresent(“involves”, false)e[0;39m
2019-02-21 10:00:15.118 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ verifyTextPresent(“involves”, false) FAILED.e[0;39m
e[31mReason:e[0;39m
e[31mcom.kms.katalon.core.exception.StepFailedException: Text ‘phani’ is not present on page e[0;39m
e[31m at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.doCall(VerifyTextPresentKeyword.groovy:79)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.call(VerifyTextPresentKeyword.groovy)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:21)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.execute(VerifyTextPresentKeyword.groovy:68)e[0;39m
e[31m at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1677)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$9.call(Unknown Source)e[0;39m
e[31m at Phani3.run(Phani3:37)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1550761195617.run(TempTestCase1550761195617.groovy:22)e[0;39m
2019-02-21 10:00:15.120 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ Test Cases/Phani3 FAILED.e[0;39m
e[31mReason:e[0;39m
e[31mcom.kms.katalon.core.exception.StepFailedException: Text ‘phani’ is not present on page e[0;39m
e[31m at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.doCall(VerifyTextPresentKeyword.groovy:79)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword$_verifyTextPresent_closure1.call(VerifyTextPresentKeyword.groovy)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:21)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.execute(VerifyTextPresentKeyword.groovy:68)e[0;39m
e[31m at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:53)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1677)e[0;39m
e[31m at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$9.call(Unknown Source)e[0;39m
e[31m at Phani3.run(Phani3:37)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:328)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1550761195617.run(TempTestCase1550761195617.groovy:22)e[0;39m
2019-02-21 10:00:15.122 e[34mINFO e[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[39mEND Test Cases/Phani3e[0;39m

Log viewer

Test Cases/Phani3 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Text ‘phani’ is not present on page
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:32)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
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:21)
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:53)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.verifyTextPresent(WebUiBuiltInKeywords.groovy:1677)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$verifyTextPresent$9.call(Unknown Source)
at Phani3.run(Phani3:37)
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:328)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:319)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:298)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:290)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:224)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1550761195617.run(TempTestCase1550761195617.groovy:22)

i did small test and try-catch block is not needed

are you sure that 2nd text is on page… and is text not an value of field or something similar?
please share how page looks like

my test:

my html page:

Thanks Andrej

This is what I am doing -

Navigate to Google.com
Search for text testing
Click on link Software testing - Wikipedia
Search for text ‘phani’ ---- not found
Search for text ’ involves’ — should be found

WebUI.navigateToUrl(‘https://google.com’)

WebUI.maximizeWindow()

WebUI.setText(findTestObject(‘Page_Google/input_Sign in_q’), ‘testing’)

WebUI.click(findTestObject(‘Page_Google/span_testing’))

WebUI.click(findTestObject(‘Page_testing - Google Search/h3_Software testing - Wikipedi’))

try {
WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE)
}
catch (com.kms.katalon.core.exception.StepFailedException sfe) {
println(’*** Text phani not found, but we can continue’)
}

//WebUI.verifyTextPresent(‘phani’, false, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.verifyTextPresent(‘involves’, false)

after click on Wiki you need to wait for page to load

WebUI.waitForPageLoad(30)

Tried but no luck…

Tried keeping only one verifystatement WebUI.verifyTextPresent(‘involves’, false) then it is finding text ‘involves’.

i got it … after 1st fail all following assertions will fail with reason same as 1st failed assertion:
i switched search for involves and phani and added assert true result after phani - fail everything

ok… Thanks Andrej

So assert true is required in these cases?..

Tried first searching ‘phani’ and then ‘invloves’ and placed assert true. It passed ‘involves’ step and assert failed…

no it’s not … assert true should always PASS as you can see, it’s failing because search for ‘phani’ fails…
what i’m trying to say is: after first FAIL all checks will fail too.
if BUG will be existence of ‘phani’ and nonexistence of ‘involves’ on page best is to use following script lines otherwise you will see FAIL exception in result …

WebUI.verifyTextNotPresent('phani', false)
WebUI.verifyTextPresent('involves', false)

Agree… But I may not know what exception messages will appear while performing any action… Lets say I am trying to save data and there is an exception on the application(due to bug). So due to this all other statements will fail… I thought it will be good to capture the success message for any validations… Please correct me