如何通过两个属性查找元素 [英] How to find element by two attributes
本文介绍了如何通过两个属性查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有单选按钮,我怎样才能点击第二个按钮,首先通过 ng-model
然后 ng-value
:
I have radio buttons like, how can I get the second one clicked finding first by ng-model
then ng-value
:
<input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=false />
<input type="radio" ng-model="vm.ist.educationVsInternship" ng-value=true />
我尝试了类似的东西
element(by.model('vm.ist.educationVsInternship')).all(by.css('[ng-value=true]')).click();
说但不点击其中任何一个
says and does not click any of them
more than one element found for locator by.model("vm.ist.educationVsInternship") - the first result will be used
还有这个:
element(by.model('vm.ist.educationVsInternship')).element(by.css('[ng-value=true]')).click();
这给了我以下错误信息:
which gives me the following error message:
失败:使用定位器找不到元素:By.cssSelector("[ng-value=true]")
Failed: No element found using locator: By.cssSelector("[ng-value=true]")
推荐答案
你可以像这样组合属性选择器:
You can combine attribute selectors like this:
$('input[ng-model="vm.ist.educationVsInternship"][ng-value="true"]')
这篇关于如何通过两个属性查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文