1

I am trying to validate the number of columns generated in a table through ranorex. For example say a car is being bought and the payment is done in 12 installments. The application does divide the amount in 12 equal installments and display them in a table. I have already put a screenshot in the report. But would like to show that there are exactly 12 columns in the table. How can i achieve this..please help.

Sensay
  • 49
  • 2
  • 9

2 Answers2

1

Get the xPath for the table with the Spy tool. And add a userCode method.

public void TestMethod()
{
    var rows = Host.Local.Find<TrTag>("/dom[@caption='Tryit Editor v3.0']//iframe[#'iframeResult']/?/?/table/tbody/tr");
    int rowNum = 0;

    foreach (var row in rows)
    {
        rowNum++;
    }

    Report.Info("Total rows: " + rowNum);
}
Martin
  • 575
  • 6
  • 13
0

If you haven't already, I would start looking into User Code for a dynamic table as a screenshot will only be useful in one scenario.

A good way I found is by using the Spy feature or during a recording use validate to click on the table you want to get. This will give you information about the table object which you can then use to get the table length:

  1. Start a recording
  2. Click on the table (make sure the highlight box targets the entire table)
  3. Stop the recording
  4. Right click on the recording step that clicks on the table (this should also be added to your repository)
  5. Click on Convert to User Code
  6. The auto-generate coded will be using the table object so you can now use this to add additional code to get the table size

The ranorex site has a lot of useful information which can help get you started: http://www.ranorex.com/support/user-guide-20/lesson-5-ranorex-recorder/user-code-actions.html

Hope this helps.

Jonnyboy
  • 136
  • 1
  • 8