If statement not working as expected:

If statement not working as expected:

I am testing a web page where “OPENED_ACCOUNT” OR “PROSPECT_CLIENT” text will display.

When “OPENED_ACCOUNT” displays my if condition works.

When “PROSPECT_CLIENT” displays my if condition DOES NOT WORK?

Has anyone see this before?

if((WebUI.verifyTextPresent(“OPENED_ACCOUNT”, false) || WebUI.verifyTextPresent(“PROSPECT_CLIENT”, false))){

println ("Text found… ")

//Delete the records found

while (WebUI.verifyTextPresent(“OPENED_ACCOUNT”, false) || WebUI.verifyTextPresent(“PROSPECT_CLIENT”, false))

{

WebUI.click(findTestObject(‘MyObject’))

WebUI.acceptAlert()

WebUI.delay(1)

WebUI.acceptAlert()

WebUI.delay(1)

}

}

1. if works always
2. if it’s not working and your logic is correct, it’s possible that there is som blank char before/after text in element you are checking try to use :

WebUI.verifyTextPresent(".*PROSPECT_CLIENT.*", true)

Dave,

Before calling WebUI.verifyTextPresent(), you should somehow ensure the Web page is loaded completely as WebUI.verifyTextPresent() does not do any wait. If the page loading is incomplete at the time of calling WebUI.verifyTextPresent(), your if statement is likely to behave unexpectedly.

1 Like

Thanks for your help folks :wink: