Can I change the CSS selection of an object during runtime?

I have a test object in the Object Repository that I can identify by the selection method CSS. In my case I have: main a[href=“topic/p1-007533”] span.
During Runtime I want to change this CSS selection to e.g.: main a[href=“topic/p1-007532”] span
Can this be done using WebUI.modifyObjectProperty? Or is there another way to do this?

Of course, you can change test object’s css value at runtime by:

import  com.kms.katalon.core.testobject.SelectorMethod

TestObject to = findTestObject('your_test_object_id')

//Change value of CSS selector
to.setSelectorValue(SelectorMethod.CSS, 'your_desired_value')

//Change selection method from another selector to CSS selector
to.setSelectorMethod(SelectorMethod.CSS)
2 Likes

Thank you very much for your quick and accurate answer. I tried it right away and it works like a charm