Weekly Katalon FAQs (4) - Katalon WebUI keywords

:point_right: See also:
Technical FAQs (1) - Browser and Testing Environment
Technical FAQs (2) - Test report


:pushpin: FAQs listed under this topic:
13. Why WebUI.click() doesn’t click in some scenarios?
14. How to resolve WebUI keywords issues such as click(), setText(), sendKeys, and run either platforms and browsers?
15. WebUI.click keyword does not work in Safari and how to solve it?


13. Why WebUI.click() doesn’t click in some scenarios?

Issue:

WebUI.click() keyword sometimes is clickable and unclickable when executing the test in different environments.

Solution:

Since Selenium 3, the maximum browsers are providing their respective browser drivers which implement WebDriver API. Selenium communicates to these browser drivers through HTTP commands, and these drivers speak natively with the browser. Official documentation of Selenium says:

“Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation.“

We can say that the way Chrome browser allows a click on a web element may be different from other browsers.

Also, when we click on a WebElement using Selenium WebDriver, it checks two preconditions before clicking:

1. The element must be visible.

2. It must have a height and width greater than 0.

If the preconditions are not satisfied, you will get exceptions stating the element is not clickable or interactable. Refer to the click() method in the official document here.

But in JavaScript, clicks do not check these preconditions before clicking. The method simulates a mouse click on an element. When click() is used with supported elements (such as an <input>), it fires the element’s click event. Reference here.

So, JavaScript (JS) could click on a web element that may not be clickable by WebDriver API. That said, to simulate actual user behaviors, we can use WebDriver. But when it doesn’t work, go for JS.

We suggest using the JavascriptExecutor like the sample below instead of using the WebUI.click() keyword:

import com.kms.katalon.core.webui.common.WebUiCommonHelper as WebUiCommonHelper

import org.openqa.selenium.WebElement as WebElement

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('your/object'),30) WebUI.executeJavaScript("arguments[0].click()", Arrays.asList(element))

14. How to resolve WebUI keywords issues such as click(), setText(), sendKeys, and run tests across platforms and browsers?

Issue:

  • Summary: A user has an automation project expected to run across platforms and browsers. Also, the user doesn’t want to customize the keyword but uses directly the Katalon keywords.
  • More detail:

The user has an automation project expected to be able to run across platforms and browsers.

These tests are being written and executed both on a co-worker’s machine (windows 10) and mine (macOS), both of us are on the latest version of the respective operating systems.
Additionally the browsers being tried are both Firefox and Chrome (latest versions as of Monday, Sept 20th)

User A and User B run the same automation project, but only User A can run the entire project successfully.

  • The differences between User A and B are Test data, Platforms, and Browsers
  • The User B cannot click on an element successfully even though he composes his own custom keywords below

Solution:

  1. Web UI Enhanced Click keyword:

First, you should know the discrepancy between Selenium WebDriver Click and JavaScript Click. A visit to this thread WebDriver click() vs JavaScript click() may give you a good understanding of this.

In 7.2.5, we shipped a built-in click keyword called [WebUI] Enhanced Click that leveraged JavaScript. You may want to send the user and advise him to try it out.

  1. Web UI sendKeys

User adds some codes to make sure the action is performed at the right timing.

The timing issue is notoriously annoying so the Smart Wait feature can be very helpful. SmartWait is enabled by default. Please make sure it is enabled.

Previously, SmartWait applied to Chrome and Firefox only. So if the users ran their tests on Edge Chromium or Headless, this could explain why they needed to do custom scripts. In 8.2.0, we support Smart Wait on Edge Chromium and make it wait for Fetch APIs. So if their website is using Fetch API, SmartWait can be of great help.

15. WebUI.click keyword does not work in Safari and how to solve it?

Issue:

WebUI.click is not working with Safari 13.1 version when trying to run on SauceLabs virtual machine.

Solution:

You can use WebUI.executeJavaScript & waitForElementClickable to handle the click action


:star2: How would you rate this FAQ topic from 1 to 5?

  • 1
  • 2
  • 3
  • 4
  • 5
0 voters

:pushpin: Katalon Community technical FAQs are about common customer technical issues when using Katalon products. We filter these on our Helpdesk Portal twice every month to help Forum users get an easy approach to the solutions to similar problems.
If you’re paid customer, you can easily submit a ticket to our dedicated Support team.


:interrobang: Haven’t got your concern tackled - leave it here!

3 Likes