How to handle data duplications in Katalon using data driven through Excel

In my code i’m using Excelsheets for the data inputs as my input values. but once i went through one execution then the next time same execution is failing due to the same value exists in the system. How can i avoid this issue? How to handle the code with the data driven?

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Unless any field has a specific format, how about just adding a datetimestamp onto the end of each of your entries that cause duplicate errors? Or perhaps, you can add a row number to your spreadsheet and include the row number for each value.

import java.time.LocalDate
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd HH:mm");

LocalDateTime localDate = LocalDateTime.now()

glocalDate = localDate.format(dateFormat).replace(':','').replace(' ','')

WebUI.verifyElementClickable(findTestObject('myPage/input_firstName'))
WebUI.setText(findTestObject('myPage/input_firstName'), findTestData('...').getValue('UserName', 1) + glocalDate)
WebUI.verifyElementAttributeValue(findTestObject('myPage/input_firstName'), "value", findTestData('...').getValue('UserName', 1) + glocalDate, 10)

If your field has a specific format, then how about just creating random numbers (Strings) and then adjusting them to your format within a Keyword, or in-line functions, and not from your Excel for these fields:

1 Like