Handling Automation challenges using Katalon Studio~ Part-1

Karthik G
upday devs
Published in
3 min readJan 8, 2021

In this blog post I will elaborate on some techniques to effectively handle the common UI automation challenges that are encountered during test automation development.

UI test automation primarily focuses on testing the business flows along with user interface and elements presented on the screen to ensure the end user experience is adequate. In this journey, we might encounter some issues such as:

  1. Handling drag and drop
  2. Handling pop-ups (alerts, custom messages)
  3. Image comparison
  4. Handling deep nested elements

All of these challenges will impact the test execution time and maintenance of scripts if not handled well. Let’s see how using Katalon’s keyword driven framework can supports us.

Handling drag and drop:

Drag and drop functionality can be handled by using Katalon’s built-in keyword dragAndDropObjectToObject which handles it natively.

As a first step, use the object spy utility to capture the droppable object and the draggable object (picture reference #2) and import them into the project’s object repository.

Note: iframe_demo-frame object is the parent iframe of both draggable and droppable objects.

For instance, let’s drag and drop the object into its target (picture reference #1) and upon dropping it successfully a custom message is displayed.

Reference #1: Draggable and droppable
Reference #2: Object repository

Script to handle the scenario using built-in keyword dragAndDropObjectToObject

//Use the dragAndDropObjectToObject keyword to perform the drag and drop actionWebUI.dragAndDropToObject(findTestObject('UI/div_draggable'), findTestObject('UI/div_droppable'))'Get the text content of our droppable object'
droppable_text = WebUI.getText(findTestObject('UI/div_droppable'))
'Verify if it is actually changed to "Dropped!" because of the drag and drop action'
WebUI.verifyEqual(droppable_text, 'Dropped!')

Handling pop-ups:

Pop-ups appear unexpectedly during the flow and cause interruptions in script executions.

Below are the most common pop-ups which might cause problems in the test automation:

  • Custom dialog box (Example: Sign-in/Privacy)
  • Alert box
  • Native window dialog box (Example: File uploading)

To handle these pop-ups, we use switchTo built-in keyword of Katalon Studio.

There are multiple associated keywords to switchTo depending on how we identify the pop-up.

If you are identifying the pop-up using the window title, we use switchToWindowTitle keyword. Similarly, we have different keywords if we identify pop-ups using window index or url.

For example, let’s consider a scenario where the pop-up (picture reference #3) appears as part of your business flow. We can handle it by using the code below:

Reference #3: Sign in popup
//Switch to window that has title 'Sign in'
WebUI.switchToWindowTitle('Sign in')

//Enter email
WebUI.setText(findTestObject('Login_Email'), email)

//Enter password
WebUI.setText(findTestObject('Login_Password'), password)
//Click on 'Sign in' button in iframe
WebUI.click(findTestObject('Page_Elated/Sign in'))

//Verify success message is displayed for successful login
WebUI.verifyTextPresent("Sign in successful",true)

Similarly to handle a native window such as file uploads, we use the switchToWindowTitle keyword along with the uploadFile keyword which specifies the path of the file.

//Upload test.png to the object 'file_input' on the UI
WebUI.uploadFile(findTestObject('file_input'), 'D:\\test.png')

To conclude, we have seen how to handle drag & drop and pop-ups using Katalon studio’s built-in keywords, which is easier to maintain/code and update.

In the next blog post, I will elaborate on handling deep nested elements using XPath (picture reference #4) and comparing images using the AppliTools plugin of Katalon studio.

Reference #4: Nested web elements

Cheers, Karthik

--

--

Karthik G
upday devs

Work hard. Have fun. Dream big. Be adventurous.