1

In my Datatable three rows are present. After clicking on Add button new row is generated and I need to put input values from datatable.

Problem: How to identify field of each row dynamically for inserting values?

Script:

 Datatable.GetSheet(5)
    rowcount=Datatable.GetRowCount
    For i=1 to rowcount
         Datatable.SetCurrentRow(i)
         lenth =Datatable.Value(1,5)
         width= Datatable.Value(2,5)
         height= Datatable.Value(3,5)
         weight=Datatable.Value(4,5)
         piece=Datatable.Value(5,5)
Browser("Magma MCR").Page("Magma MCR").WebEdit("ship_info1[length_val]"Set lenth 
Browser("Magma MCR").Page("Magma MCR").WebEdit("ship_info1[width_val]").Set width 
Browser("Magma MCR").Page("Magma MCR").WebEdit("ship_info1[height_val]").Set height 
Browser("Magma MCR").Page("Magma MCR").WebEdit("ship_info1[weight_val]").Set weight 
Browser("Magma MCR").Page("Magma MCR").WebEdit("ship_info1[total_pieces]").Set piece

In this script,

Here in first row, web element name is "ship_info1[height_val]"

for next added row, web element gets chnaged to "ship_info2[height_val]"

So, I want to select this web-element dynamically. Please see the attached image. enter image description here

0

As per my understanding you want to dynamically fetch values for all the Ship info's , so in that case as you are keeping a loop for every row, you need to just put the code of updating values inside the loop and use Regular expression for Ship_info name, a wildcard for Ship_info.* for handling 1 ,2 etc values of different rows and also you can handle the same in loop by Ship_info.i . There are multiple ways to handle this case.

Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.