Search code examples
c#automated-testsatata

Atata – How to check hidden checkbox within table?


I am using Atata Framework and working on the following scenario—There's a table with checkbox within TD element. I want to be able to invoke Click() method on the checkbox, but couldn't get it work correctly.

The truncated HTML is as following:

<table data-v-c4547572="" class="invGrid">
        <tr data-v-c4547572="" row-id="3ed5bcf4-473d-43ae-991a-ffe36d5e0a53" class="row-index-0">
            <td data-v-c4547572="" class="column-index-0 checkbox-col">
                <input data-v-c4547572="" type="checkbox" element-id="3ed5bcf4-473d-43ae-991a-ffe36d5e0a53" class="">
                <label data-v-c4547572="" for="3ed5bcf4-473d-43ae-991a-ffe36d5e0a53"></label>
            </td>
            <td data-v-c4547572="" class="column-index-1">
                <span data-v-c4547572="" class="val-name">Some text</span>
                <span data-v-c4547572="" class="arrow pull-right dsc"></span>
            </td>
        </tr>
    </tbody>
</table>

The code I'm using is:

// The page class:

[FindByCss(".invGrid")]
public Table<GroupsRow, Page> Inventory { get; set; }

// The row class:

public class GroupsRow : TableRow<Page>
{
    [FindByIndex(0)]
    public CheckBox<Page> CheckBox { get; set; }

    [FindByCss(".val-name")]
    public Text<Page> Text { get; set; }
}

As an additional note, invoking Exists() on the checkbox yields false:

inv.CheckBox.Exists(); // false

Any idea how to make the checkbox to be operational?


Solution

  • I can guess that your check box is actually hidden, and <label> is used as a wrapper for custom rendering. As almost all controls in Atata are looking for visible elements by default, you can specify Visibility:

    [FindByIndex(0, Visibility = Visibility.Any)]
    public CheckBox<Page> CheckBox { get; private set; }
    

    It should find the check box. But if click on it will not work (as it can be hidden), you can add a property for label and click it:

    [FindFirst]
    public Label<Page> CheckBoxLabel { get; private set; }