Adding new object properties

Hello, is it possible to add new object properites manually?
Im trying to add new property to an object but it cannot find it when running the test. Even better when I change the name of the original property ‘text’ to → ‘text1’ it breaks the tests and is unable to find the object.

You can create a TestObject in code by adding properties, like an xpath, so yes, you should be able to add properties of something else. However, first you should review the below link and then my comments below.

Here I create a TestObject:

      xpath = "//input..."
      TestObject tObj = new TestObject(xpath)
      tObj.addProperty("xpath", ConditionType.EQUALS, xpath) 

So, you can try and play with the below:

import com.kms.katalon.core.testobject.ConditionType

myText = "..."
findTestObject('myPage/input_Categories')).addProperty("text()", ConditionType.CONTAINS, myText ) 

And if you only want to compare text, then maybe you can compare an element’s text without doing it as above by using:

myText = WebUI.getText(findTestObject(...))
WebUI.verifyMatch(myText, "here is your text", false)

Edit: I had a last thought that you can try something like below:

import com.kms.katalon.core.webui.common.WebUiCommonHelper

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('myPage/input_Categories'), 10);
WebUI.verifyMatch(element.getAttribute("class").contains("disabled").toString(), "true", false)
1 Like

Thanks for all the tips, I will try them out and get back with the results