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.

Hello

I followed the above steps but didn’t work-
Below are my steps

  1. Found out the number of elements in a list ,using count elements and stored in a param. This gave me the correct count .

  1. used Get text and passed the parameter in the Xpath ,stored the value in another param.

  1. I dont need to use any mathematical expression to subtract but tries that as well .

4.Grouped both the test cases .

  1. Final test case

  1. Added conditions in the grouped test case.

ISSUE:
If I run get text script alone , it shows me the device name on the 12th position .
but running as a group returns no message and runs the given max 15 repeat whereas the total count from the element is 12.

Please help if I am missing anything.

Hi @it.dishantrawat.

Please make sure you are using PROJECT PARAMETERS.
I see in the screenshots that you used Test Parameters.

This topic was automatically closed after 180 days. New replies are no longer allowed.