Hi,
Is there any way where I can use the Object from object repository in selenium code.
import org.openqa.selenium.By
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
WebDriver driver = DriverFactory.getWebDriver()
driver.findElement(By.xpath("element xpath from katalon object Repository"))
If there is any way or method please share some example.
you are looking for:
driver.findElement(By.xpath(findTestObject('path/in/OR').findPropertyValue("xpath"))
2 Likes
Thanks yeah its working awesome
I tried the code - findTestObject(“Object Repository/ABC Repository/Login/Join_Button”).findPropertyValue(“xpath”)
It is returning empty string. Can you help on this?
Note: I am automating a mobile app
try
driver.findElement(By.xpath(findTestObject(‘Object Repository/ABC Repository/Login/Join_Button’).getSelectorCollection().get(findTestObject(‘Object Repository/ABC Repository/Login/Join_Button’).getSelectorMethod()))
or, as a function
public static String getSelector(TestObject to){
String selector=to.getSelectorCollection().get(to.getSelectorMethod())
assert selector.length()!=0
return selector
}
on a sidenote, i’ve had situations where it returned an empty string, but the fix for that was to edit the testobject, save, undo the changes, save