Creation of Test Object in Object Repository in Runtime


#1

Hi,
Since Katalon performs all the UI validations based on the TEST OBJECT(which is defined in Object Repository) , is it possible to Create new TEST Object during runtime ? If possible kindly share your inputs ?

As we can see, there’s way to modify existing TEST OBJECT from object repository folder using WebUI.modifyObjectProperty. Am looking for a way to create test objects during runtime.

It will be really helpful. Thanks in Advance.


#2

Hi Indurajan

I use this:

  /**
   * Construct a Katalon-compatible TestObject in memory.
   * @param css (String) The CSS selector used to find the target element.
   * @return (TestObject) The constructed TestObject. 
   */
  static TestObject makeTO(String css) {
    TestObject to = new TestObject()
    to.addProperty("css", ConditionType.EQUALS, css)
    return to
  }


#3

Hi Russ Thomas,
Thanks for your reply. As per your code, it will just add property to existing Object from object repository.

Is there a way to insert new TEST object into Object Repository during runtime ? Kindly ,share your inputs, Thanks in advance


#4

Hi Russ,
Code worked for me . thanks for the inputs :slight_smile: .


#5

Hi Indurajan

As per your code, it will just add property to existing Object from object repository.

No, it specifically creates a new TestObject, in memory and adds a css property to it.

Is there a way to insert new TEST object into Object Repository during runtime ?

No, I don’t think so. And, if you think about it, it’s probably not a very good idea: imagine the amount of one-off TOs you might end up with in your repository.


#6

Personally, I agree with Russ on this issue. If the TestObject can be created physically, any mistake from the test script will destroy the project with hundreds of unexpected objects.


#7

Russ Thomas said:

Hi Indurajan

I use this:

  /**
  • Construct a Katalon-compatible TestObject in memory.
  • @param css (String) The CSS selector used to find the target element.
  • @return (TestObject) The constructed TestObject.
    */
    static TestObject makeTO(String css) {
    TestObject to = new TestObject()
    to.addProperty(“css”, ConditionType.EQUALS, css)
    return to
    }

  

  

Hi Russ Thomas,

How to set Shadow Root Parent to this object?


#8

Does this have to be a css selector? I mean can’t we us xpath or id or name?


#9

Just replace “css” string with any other property.