Dynamic radioButton

I have one question i need to click on dynamic radioButton

the name=“402242[pre_risk_accept]” always changes when the new client registered i have this id of new client for now it is 402242.
is there some features how i can find on webpage the needed radio buddon by this ID

If the ID is dynamic, then it will be useless to you. Try using something else thats unique to locate it, maybe the value ?

i can get this ID by making select to database, so i need only to find the radiobutton with this id on the webpage =) i find some information about trying to use XPATH

TestObject to = findTestObject('/Page/input_Accept_402278pre_risk_accept')
// get Map with <SelectorMethod, String> pair
Map allSelectors = to.getSelectorCollection()

// println original value of XPATH selector

// update the value
to.setSelectorValue(SelectorMethod.XPATH, '//input[@name=\''+ substresult +'[pre_risk_accept]\']')

// println new value of XPATH selector
allSelectors = to.getSelectorCollection()


but i dont know how i can adjust it for searching the radio button on the page.

For example i have the radio button :



if i somehow change this input to name what i need the katalon will find the needed radio button?
For example now there are id 402278 if i put there needed id to me 402279 katalon will find new radio button?

Yes it will but you dont want to have to change it each time, click on attributes and send another screen shot of the screen you have please

Ok so if you use attributes to locate the element, and just use type and value, you should be fine every time

1 Like

but how can i adjust this attributes to radio button every time? is there any methods, i can’t find any in google :persevere:

You will have to change it manually

1 Like

but are there any methods how can i automatically change object properties ->name (402278[pre_risk_accept])
if there is, my problem will be solved :slight_smile:

You can use on the script modifyObjectProperty keyword


Yes Thank you i already find it too ))) and have automatically change object properties all is working!

CustomKeywords.'demomysql.Demo.connectDB'('demo.db', 'database', '3306', 'user', 'test')
clientID = CustomKeywords.'demomysql.Demo.executeQuery'('select id from contracts where user_id = '+ substresult +';')
String dinamycclient = clientID + '[pre_risk_accept]'

TestObject yourObject = WebUI.modifyObjectProperty(findTestObject('Page/input_Accept_402278pre_risk_accept'), 'name', 'equals', dinamycclient , true)