waitForElementVisible not working quite right in If statement

I’ve got an odd case where the waitForElementVisible is correctly returning true but the test case is still hitting my failure statement. Can someone help me spot what I’m doing wrong? The “test” declaration I threw in there returns as true and I can see the element on the page - I’m not getting it!
Thank you!

test = WebUI.waitForElementVisible(findTestObject(divSpons), 10)

if (WebUI.waitForElementVisible(findTestObject(divSpons), 10) == false)
	{
	WebUI.takeScreenshot()
	throw new AssertionError('ERROR: Correct Product not available')
	}

Looks as though you’re missing the Failure Handling argument.

WebUI.waitForElementVisible(findTestObject(divSpons), 10, FailureHandling.CONTINUE_ON_FAILURE)
WebUI.waitForElementVisible(findTestObject(divSpons), 10, FailureHandling.OPTIONAL)

Thanks Russ! Unfortunately I don’t think that’s it, it still returns true, hits the If statement and fails.

2019-07-24 16:11:00.606 WARN k.k.c.w.k.b.WaitForElementVisibleKeyword - Object ‘Object Repository/Card Template/Retailer/divSpons’ is not visible after 10 second(s)

I think something is going on with the object I’m using. I’m going to continue on that thought and will let you know if I need further assistance. Thanks, as always! :slight_smile:

1 Like

Okay, so because…

Then why not…

test = WebUI.waitForElementVisible(findTestObject(divSpons), 10) 
if (test == false) { 
  WebUI.takeScreenshot() 
  throw new AssertionError('ERROR: Correct Product not available') 
}

and if that works, report a bug – because there’s something screwy going on.

I replaced the object in the object repository though I could see ABSOLUTELY nothing wrong with it and like magic… it works! :woman_facepalming: Thanks for entertaining… sigh…

1 Like