Forum Discussion

rdpatil's avatar
rdpatil
Occasional Contributor
7 years ago

how to Select & deselect Angular Checkbox , Not have ischecked Property in Name Mapping

Team, I am new to TestComplet. I have to verify that the checkbox is checked or not & Take the action. (Checkboxes in different rows) Need to parameterize it.

Basically its a toggle checkbox, not having is-checked Property to Verify it. The checkbox is inside the cell. 

 

Html code for checked checkbox =

<i class="btn fa fa-lg fa-check-circle-o" aria-hidden="true" ng-class='{" fa-check-circle-o": dataItem.Selected, "fa-circle-thin": !dataItem.Selected}' ng-click="vm.toogleSelection(dataItem)"></I>

 

Html code for un-checked checkbox =

<i class="btn fa fa-lg fa-circle-thin" aria-hidden="true" ng-class='{" fa-check-circle-o": dataItem.Selected, "fa-circle-thin": !dataItem.Selected}' ng-click="vm.toogleSelection(dataItem)"></I>

 

 

Thank You in Advance.

1 Reply

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > I have to verify that the checkbox is checked or not

    As it can be seen from the HTML source code and Object Browser in TestComplete, your checkbox is just an empty <i> element inside <td>. <td> is recognized by TestComplete as Cell and this is how it was mapped in NameMapping. Because <i> is an empty tag it is not present in the Object Browser and is not natively recognized and supported by TestComplete.

    With this background knowledge, your actions may be like this:

    a) Get the needed table cell;

    b) Using the cell as a root, search for its <i> native child and get the value of its class attribute;

    c) Check whether the obtained value contains the substring that is present only when checkbox is selected (fa-check-circle-o) and proceed appropriately.

     

    To get the cell (point a) ), you may either use NameMapping (like in the recording that you provided) or search for it using FindChild() method.

    Assuming that you already have a cell object, use FindChildByXPath() method to get <i> child and the value of its class attribute. I cannot verify exact XPath at the moment, but it may look like this:

    classValue = table.cell.FindChildByXPath("./i/@class")

    (that stands for: get value of the class attribute for the 'i' child of current element)