[WebUI] Find Web Elements
Description
Find web elements by test object.
Keyword name: findWebElements
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
Param | Param Type | Required | Description |
---|---|---|---|
to | TestObject | Yes | Represent a web element. |
timeout | int | Optional | Maximum 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 elements or null
if cannot find any.
Example
You want to find all social networking icons 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 for the browser to be stable
WebUI.delay(3)
TestObject testObj = findTestObject('icon_Social_networking')
List<WebElement> elements = WebUI.findWebElements(testObj, 10)
for (int i = 0; i < elements.size(); ++i) {
KeywordUtil.logInfo(elements.get(i).toString())
}
See also: