无法使用leftOf选中复选框 [英] Unable to select the check box using leftOf

查看:54
本文介绍了无法使用leftOf选中复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图单击文本(作为服务器)左侧的复选框.

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

我的HTML代码如下.

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>

以上代码段的Ui

我浏览了空手道文档,并尝试了多种方案,但是没有一个能够找到该复选框.

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

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

输出:评估(js)失败:leftOf('{} as-server').find('input [type ="checkbox"]').click(),java.lang.RuntimeException:找不到:{}作为服务器,左侧,输入[type =" checkbox"] 堆栈跟踪:com.intuit.karate.driver.ElementFinder.find(ElementFinder.java:120)

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)

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

输出:评估(js)失败:leftOf('{} as-server').click(),java.lang.RuntimeException:找不到:{} as-server,LEFT,INPUT 堆栈跟踪:com.intuit.karate.driver.ElementFinder.find(ElementFinder.java:120)

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?

谢谢!

推荐答案

UI测试并不容易.可能有很多原因,例如您正在使用的Angular可能会在页面上做一些额外的事情并隐藏元素区域.所述友好定位器"包括:这样做很方便,但是如果无法立即使用它们,则应该花一些时间进行故障排除.如果您遵循此过程,那么我们将可以改善框架,这将是很好的: https://github.com/intuit/karate/tree/develop/examples/ui-test

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()

这篇关于无法使用leftOf选中复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆