How to deal with duplicate fields

Hi,

I’ve run into an issue where I have two of the same fields on the same page and katalon is unable to differentiate between the two. For example, the test case is creating a user providing a first name, last name, email, and phone number. You then have the option to create a second user at which point first name, last name, email, and phone number appear again. When Katalon runs the test, it appends the 2nd user data into the first users fields. Any thoughts on how I can get around this?

That’s hard to envisage without screenshots.

Please follow this advice:

Absolutely, thanks for the response. Hopefully this helps.

WebUI.setText(findTestObject(‘Object Repository/Page_RP/input_First Name_firstName’),
‘Dominique’)

WebUI.setText(findTestObject(‘Object Repository/Page_RP/input_Last Name_lastName’),
‘Wilkins’)

WebUI.setText(findTestObject(‘Object Repository/Page_RP/input_Phone Number_phoneNumber’),
‘4047706262’)

WebUI.setText(findTestObject(‘Object Repository/Page_RP/input_Email_email’),
‘dwilkins123123@hawksmail.com’)

WebUI.click(findTestObject(‘Object Repository/Page_RP/span_Add Another Admin’))

WebUI.setText(findTestObject(‘Object Repository/input_First Name_firstName’),
‘Michael’)

WebUI.setText(findTestObject(‘Object Repository/input_Last Name_lastName’),
‘Jordan’)

WebUI.setText(findTestObject(‘Object Repository/input_Phone Number_phoneNumber’),
‘4047702345’)

WebUI.setText(findTestObject(‘Object Repository/input_Email_email’),
‘mjthegoat@3peat.com’)

You seem to be missing a delay of some description.

When you click the “add another” link/button, the form very likely needs time to reset.

Try this mehod:

WebUI.waitForElementAttributeValue(findTestObject('Object Repository/Page_RP/input_First Name_firstName'), 'value', '', 10)

// Repeat for all other required fields...

Thanks for the feedback. I gave this a shot but still ended up with the same result. They key problem is when I do a web spy, both “First Name” fields are in the same repository. When Katalon is adding the text to first name “input_First Name_firstName”, it can’t tell it apart from the 2nd one (2nd user). Is there a different reference I can use for the second first name, last name, phone, and email fields so that Katalon knows to populate the new fields instead of adding to the first?

Take a screenshot of the HTML in DevTools. Take another screenshot of the HTML when you are about to add the second user.