Skip to main content

[WebUI] Find Web Element

Description

Find web element by test object.

Keyword name: findWebElement

Note:
  • If you want to click using the click() keyword, you need to manually switch to iframe with the [WebUI] Switch to Frame keyword.

Parameters

ParamParam TypeRequiredDescription
toTestObjectYesRepresent a web element.
timeoutintOptionalMaximum period of time (in seconds) that system will wait to return a result. If not specified, Studio will use the default timeout value in Project Settings.

Returns

The found Selenium web element or null if cannot find any.

Example

You want to find the Facebook icon on the https://katalon-demo-cura.herokuapp.com/ demo website using a test object.

import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.util.KeywordUtil
import org.openqa.selenium.WebElement
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.testobject.TestObject as TestObject

WebUI.openBrowser('https://katalon-demo-cura.herokuapp.com/')
// Wait until the brower's stable
WebUI.delay(3)

// Create a test object. This is the Facebook icon on the demo website
TestObject testObj = findTestObject('icon_Facebook')
WebElement anElement = WebUI.findWebElement(testObj, 5)
KeywordUtil.logInfo(anElement.toString())