1

I am trying to click a check box which is left to the text(as-server).

My HTML code looks like this.

<td>
     <input type="checkbox" ng-model="asset.isChecked" ng-change="selectEntity(filteredTableElements,asset.id)" class="ng-valid ng-dirty ng-valid-parse ng-empty ng-touched">
</td>                                       
<td class="ng-binding">as-server</td>

The Ui for the above snippet enter image description here

I went through the Karate doc and tried multiple scenarios but none of them were able to find the checkbox.

Scenario1:

* leftOf('{}as-server').find('input[type="checkbox"]').click()

output: evaluation (js) failed: leftOf('{}as-server').find('input[type="checkbox"]').click(), java.lang.RuntimeException: unable to find: {}as-server, LEFT, input[type="checkbox"] stack trace: com.intuit.karate.driver.ElementFinder.find(ElementFinder.java:120)

Scenario2:

* leftOf('{}as-server').click()

Output: evaluation (js) failed: leftOf('{}as-server').click(), java.lang.RuntimeException: unable to find: {}as-server, LEFT, INPUT stack trace: com.intuit.karate.driver.ElementFinder.find(ElementFinder.java:120)

Did I miss something here? Is there any other way of doing it in Karate?

Thanks!!

1 Answers1

0

UI testing is not easy. There can be many reasons, for e.g. Angular that you are using may be doing some extra things on the page and hiding element areas. The "friendly locators" are there as a convenience, but if they don't work out of the box, you should spend some time troubleshooting. It would be great if you follow this process so that we can improve the framework: https://github.com/intuit/karate/tree/develop/examples/ui-test

So maybe you should just try another approach and Karate gives you plenty. For example:

* locate('{}as-server').previousSibling.firstChild.click()
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248