I have a table where each time I have to enter a new row and enter some value on the newly added row. The structure look like this
The challenge is each time, the newly added row will have dynamic IDs such as disputeCauseSubviewId:disputeCauseFormId:disputeCauseDataTableId:1:disputeCauseInputField
How can I write a script where I can find out the empty row and enter some value. Please suggest.
Hi, you can try to use CSS Locator. I noticed that the inputs although have different Ids but the same class. Here are the steps you may try:
- First retrieve all web elements with the class dm_disputeCause-dataTable_textField.
- Iterate over these elements, in each iteration you check:
– If the element doesn’t contain text, then set your text in here and terminate the loop.
– Else keep iterating.
Please try it yourself and let us know where you get stuck.
Thanks for the quick response.
I managed to find another solution (i am not sure whether its the right way, but it worked ) . I captured the blank row and added a new property as value and kept that as empty as showed below.
and I unchecked all other propertie. Somehow it worked and now I am able to enter value for the blank field. My scripts is as follows.
WebUI.click(findTestObject(‘Dispute Management - Dispute Cause/Page_eSDMS - root/input_Cause Of Dispute_disputeCauseSubviewId’)) — for adding a new row
WebUI.setText(findTestObject(‘Dispute Management - Dispute Cause/Page_eSDMS - root/Page_eSDMS - root/input_Cause Of Dispute_disputeCauseSubviewIddisputeCauseFormIddisputeCauseData’),
‘testing 2’) – for setting the text in the newly added row
WebUI.click(findTestObject(‘Dispute Management - Dispute Cause/Page_eSDMS - root/input__disputeCauseSubviewIddisputeCauseFormIdsaveButton’)) – for saving the newly added row
Is it a proper solution, I am wondering.
It’s a valid solution. I think it works because a newly added row always has an empty value property, so by identifying the object with nothing but the blank value property you can always find an empty row.
Could you please show how to find all the input fields and then iterate them to know if them are fulfilled or not?
It is posible by writing katalon groovy script or should I unwrap to code into selenium way and do findelements() like selenium webDriver Does with java?
I think the ideal way would be to use findElements() of Selenium. Then you can iterate over the returned web elements and convert them into Katalon’s test objects and then you can use the functionalities provided in WebUI to get/set text.