如何通过两个属性找到元素 [英] How to find element by two attributes

查看:152
本文介绍了如何通过两个属性找到元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个单选按钮,我怎样才能得到第二个点击通过 NG-模型先找到然后 NG-值

 <输入类型=电台NG-模式=vm.ist.educationVsInternshipNG-值= FALSE /><输入类型=电台NG-模式=vm.ist.educationVsInternshipNG值=真/>

我想是这样

<$p$p><$c$c>element(by.model('vm.ist.educationVsInternship')).all(by.css('[ng-value=true]')).click();

说,不点击其中任何一个

 多个元素发现定位by.model(vm.ist.educationVsInternship) - 的第一个结果将被用来

和这样的:

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

这给了我

 失败:没有使用定位器找到的元素:By.cssSelector([NG值=真])


解决方案

您可以将属性选择是这样的:

  $('输入[NG模型=vm.ist.educationVsInternship] [NG-值=真]')

I have radio buttons like, how can I get 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

 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屋!

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