0

I want to verify if the element is not visible in viewport then scroll to that element, do the click and if already visible in viewport then directly click on the element For this i am using

if (WebUI.verifyElementNotInViewport(TestObject obj, int timeout) == true) {
WebUI.scrollToElement(TestObject obj, 10)
WebUI.click(TestObject obj)
} else {
WebUI.click(TestObject obj)
}

Here else should be executed if the element is visible and in viewport, but I am getting error "is present but is visible in viewport" I tried the WebUI.verifyElementInViewport too, but with if the element is not in viewport then I am getting error "is present but is not visible in viewport"

Dipak
  • 53
  • 8
  • There seems to be a problem with `WebUI.verifyElementNotInViewport()`: https://forum.katalon.com/discussion/6018/verify-element-in-viewport-problem, https://forum.katalon.com/discussion/7474/verify-element-in-viewport-not-working-correctly, https://forum.katalon.com/discussion/9674/webuiverifyelementinviewport-method-gives-two-different-results-for-debug-passed-and-run-failed. Have you tried using `WebUI.verifyNotVisible()`? – Mate Mrše Nov 14 '18 at 07:55
  • I tried WebUI.verifyElementNotVisible(), Still the same result: I am getting error Object 'Object Repository/Menu/submenu1' is visible – Dipak Nov 14 '18 at 16:07
  • Please share your HTML, your complete script and error logs. It will be faster that way. – Mate Mrše Nov 15 '18 at 07:09

1 Answers1

0

You need to set a Failure Handling after the timeout parameter.

WebUI.verifyElementNotInViewport(TestObject obj, int timeout, FailureHandling flowControl) Katalon webui-verify-element-visible-in-viewport

In your case "FailureHandling.OPTIONAL" if you don't want your test to fail. Katalon default-failure-handlingbehavior