How to find element by two attributes

烂漫一生 提交于 2019-12-30 13:12:30

问题


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 />

I tried something like

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

and this:

element(by.model('vm.ist.educationVsInternship')).element(by.css('[ng-value=true]')).click();

which gives me the following error message:

Failed: No element found using locator: By.cssSelector("[ng-value=true]")


回答1:


You can combine attribute selectors like this:

$('input[ng-model="vm.ist.educationVsInternship"][ng-value="true"]')


来源:https://stackoverflow.com/questions/32318396/how-to-find-element-by-two-attributes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!