Mastering Tab Navigation with Katalon Studio

mastering tab navigation katalon studio

Need to press Tab right after a page loads in Katalon Studio and check which element gets focus? This community-inspired guide walks through opening the page, waiting for it to load, and sending Tab with Selenium Actions.

Key takeaways
The 30-second version of this article
WebUI.sendKeys needs a target test object, so it can't press Tab from the top of a page before anything has focus.
Open the browser, navigate to the URL, and wait for the page to load before sending keys.
Use Selenium's Actions class via DriverFactory.getWebDriver() to send Tab to the page itself.
Read document.activeElement with WebUI.executeJavaScript to verify which element received focus.

Hello, Katalon users and software testing enthusiasts! Today, we’re diving into a common challenge that many of you have encountered: navigating through a web page using the ‘Tab’ key. This blog post is inspired by a real-life scenario shared by a Katalon user on our community forum.

The Challenge

The user was trying to automate a test case where they needed to launch a browser, open an application URL (like google.com), and once the page loaded, press the Tab key to verify that the first element in focus was a specific element. They had used WebUI.sendKeys(findTestObject('Object location'), Keys.chord(Keys.TAB)) successfully in the past, but in this case they couldn't set focus on the page and press Tab.

The Solution

Let’s break down the solution into simple steps:

Step 1: Launch the Browser and Open the URL

First, we need to launch the browser and open the application URL. This can be done using the WebUI.openBrowser('') and WebUI.navigateToUrl('https://www.google.com') commands in Katalon Studio.

Step 2: Wait for the Page to Load

Next, we need to make sure the page has fully loaded before proceeding. We can use the WebUI.waitForPageLoad(5) command, which waits for the page to load within a specified timeout (in this case, 5 seconds).

Step 3: Set Focus and Press Tab

Now comes the tricky part. WebUI.sendKeys(findTestObject('Object location'), Keys.chord(Keys.TAB)) needs a test object to send keys to, so it doesn't help when you want to press Tab from the top of the page before any element has focus. Instead, send the key to the page itself with Selenium's Actions class, then check which element received focus:

import org.openqa.selenium.Keys
import org.openqa.selenium.WebDriver
import org.openqa.selenium.interactions.Actions
import com.kms.katalon.core.webui.driver.DriverFactory

WebUI.openBrowser('')
WebUI.navigateToUrl('https://www.google.com')
WebUI.waitForPageLoad(5)

// Press Tab on the page without targeting a specific element
WebDriver driver = DriverFactory.getWebDriver()
new Actions(driver).sendKeys(Keys.TAB).perform()

// Log the element that now has focus so you can verify it
String focused = WebUI.executeJavaScript('return document.activeElement.outerHTML', null)
WebUI.comment(focused)

You can then compare the focused element with your expected test object, for example by checking its ID or name attribute.

Conclusion

Navigating through a web page using the ‘Tab’ key can be a bit tricky, but with the right commands and a bit of patience, it’s definitely achievable. Remember, the Katalon Community forum is a great resource for finding solutions to common challenges.

The information in this blog post is based on a real-life scenario shared by a user on our Katalon Community forum and is intended to inspire peer-to-peer discussion and collaboration. Please always test solutions thoroughly before implementing them in a production environment.

Feel free to continue the discussion on the Katalon forum.

Frequently asked questions

Thong Tran
Thong TranSenior Software Engineer

Thong Tran is a Senior Software Engineer at Katalon, where he helps build Katalon Studio. He brings a people-first mindset to engineering and focuses on creating real value for users rather than chasing tech trends. Beyond his engineering work, he regularly shares product knowledge with colleagues and supports the Sales team.

Get started

Test everything. Ship with confidence.

From generating test cases to spotting failures, Katalon's AI works across your entire pipeline, automatically.

Live webinar

The Next Evolution of Manual Testing: Introducing Katalon AI Test Runner

Learn how to grow your QA team's capacity in the age of AI, then watch Katalon AI Test Runner turn manual test cases into automated runs, live.

2:00 to 3:00 PM IST
Almas AhmedSenior Account Manager
Sumit WankhedeSolutions Engineer Manager
Register now