TestProject Forum

How to handle dynamic rows in table

Hi all,

am using testproject in my project .i had stuck in below point .please some one help me out.


2.

i want to add those highlighted row values and match them with total .here when we click add line button system added one more line.as like 2nd image.so xpath is changed for total cell.so each time add lines total xpath cell is different so.how can i handle this situation

1 Like

Hi @mani_mpart .

Please take a look on the following example and try to adapt to your test case:

Here I will create a loop that get all the “Price” and I’ll sum them:

  • The first step will be finding a locator that matches all the elements I want. I can check it using the Locator tab:

  • Then, I’ll manually add a step that count the number of elements and store the value into a project parameter(that has a default value equals to 35):

  • The next step will be getting the value of the element and storing it into a parameter. NOTE: The element locator must depend on the parameter we created in the first step :

  • Then, as I want to sum all values, I’ll create a new parameter called “Total_value” with default value “0”, and I will add a step that makes a mathematical expression:

  • Now, I need to add a step that decreases “1” of the value of the parameter “Number_of_elements_total” :

  • After adding all these steps, I am ready to create my loop.
    To achieve that, first we will need to group our steps into a test(except the one that counts the number of elements) and give it a name(Let’s call our subtest “Get values and sum”).
    NOTE: Once you grouped the steps, there is no “ungroup” optio, so I suggest to duplicate all steps.

This is how you can group the steps:

  • Now, let’s add a loop to this subtest with a condition. We can achieve that by opening the advanced options of this subtest:

That’s it, we can execute our test now :slight_smile:

Try to adapt this example to your test case and let me know if you need any help.

Kind regards,
Ricardo.