protractor 中的$与$$
来源:互联网 发布:康有为知乎 编辑:程序博客网 时间:2024/06/05 08:57
protractor API
以下内容仅代表个人观点,欢迎指点,补充~
element.all中有个$$
用CSS查找元素数组的简写函数。element.all(by.css('.abc'))相当于$$('.abc');
view
<div class="count"> <span class="one">First</span> <span class="two">Second</span></div>
code
// The following two blocks of code are equivalent.let list = element.all(by.css('.count span'));expect(list.count()).toBe(2);expect(list.get(0).getText()).toBe('First');expect(list.get(1).getText()).toBe('Second');// Or using the shortcut $$() notation instead of element.all(by.css()):let list = $$('.count span');expect(list.count()).toBe(2);expect(list.get(0).getText()).toBe('First');expect(list.get(1).getText()).toBe('Second');从上图的例子中可以看到element.all也就是当前页面的所有元素,通过css的选择器选择到类名为count下的span标签
另外还是element下有$与$$,在我的理解中$与$$的区别是$是查找单个元素,而$$是查找一个数组,也就是一类元素
调用$可以被链接到父元素中查找元素
view
<div class="parent"> <div class="child"> Child text <div>{{person.phone}}</div> </div></div>code
// Chain 2 element calls.let child = element(by.css('.parent')). $('.child');expect(child.getText()).toBe('Child text\n555-123-4567');// Chain 3 element calls.let triple = element(by.css('.parent')). $('.child'). element(by.binding('person.phone'));expect(triple.getText()).toBe('555-123-4567');// Or using the shortcut $() notation instead of element(by.css()):// Chain 2 element calls.let child = $('.parent').$('.child');expect(child.getText()).toBe('Child text\n555-123-4567');// Chain 3 element calls.let triple = $('.parent').$('.child'). element(by.binding('person.phone'));expect(triple.getText()).toBe('555-123-4567');
-------------------------------------------------1-------------------------------------
调用$$可以被链接以查找父元素中的数组
view
<div class="parent"> <ul> <li class="one">First</li> <li class="two">Second</li> <li class="three">Third</li> </ul></div>code
let items = element(by.css('.parent')).$$('li');// Or using the shortcut $() notation instead of element(by.css()):let items = $('.parent').$$('li');个人理解:element.all中的$$就是根据css选择器来查找元素,单个或多个都适应
element中的$与$$就会分一些情况来选择使用,例如是ul下的多个元素则使用$$
总的来说就是 : $$的使用范围大于$,$$可以是单个也可以是多个,$只能是单个
阅读全文
0 0
- protractor 中的$与$$
- protractor中的browser.get
- Protractor
- Protractor小结
- AngularJs专用测试工具Protractor 搭建PhoneCat项目的开发与测试环境
- protractor 环境搭建
- protractor设置cookie登录
- protractor 添加测试报告
- Protractor版本大事记
- Protractor 环境搭建
- protractor元素无法点击
- Angular + protractor + mocha
- 搭建一个protractor项目
- This is a re-invention of protractor!
- Scala + Play + Sbt + Protractor = One Build
- 在Grunt task中集成Protractor
- 用protractor测试canvas绘制(一)
- 用protractor测试canvas绘制(二)
- C#串口传输中文字符
- Android中使用JAVA原始URL的GET请求数据,可能出现乱码的解决办法。
- 【业界实战】小米大数据总监司马云瑞详解小米用户画像的演进及应用解读
- 大数相乘
- Struts2学习---拦截器+struts的工作流程+struts声明式异常处理
- protractor 中的$与$$
- shiro中出现Caused by: java.lang.IllegalStateException: Configuration error: No realms have been config
- 理解HTML语义化(WEB语义化)
- 构建私有registry
- balst-2.7.1+ 本地化
- java安全沙箱(二)之.class文件检验器
- SVN 配置
- 区块链技术术语表
- 1049. 数列的片段和(20)