WebElement的量角器的getText直放站阵列 [英] Protractor getText of WebElement in repeater array

查看:160
本文介绍了WebElement的量角器的getText直放站阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML页面中我有:

In an html page I have:

<ul class="phones">
              <li ng-repeat="phone in phones | filter:query | orderBy: orderProp">
                {{phone.name}} - {{phone.age}}
                <p>{{phone.snippet}}</p>
              </li>
            </ul>

在一个端到端的测试我已经(正在返回数组中的两个元素):

In an e2e test I have (is returning two elements in the array):

            var result= ptor.findElements(protractor.By.repeater('phone in phones').column('phone.name'));

            result.then(function(arr) {
                arr[0].getText().then(function(text) {
                    console.log("*** 1: "+ text);
                });

                arr[1].getText().then(function(text) {
                    console.log("*** 2: "+ text);
                })
            });

在控制台打印所有三列,phone.name,phone.age和phone.snippet。
为什么选择不只是返回phone.name?

The console is printing all three columns, phone.name, phone.age, and phone.snippet. Why is the selector not just returning phone.name?

它实际上返回无论我在列表中的礼,纯文本或有约束力的。

Its actually returning whatever I have in the list "li", plain text or a binding.

推荐答案

这个例子试图查找与下面的战略要素(柱部分固定为每个评论)

The example tries to locate elements with the strategy below (column part is fixed as per comments):

protractor.By.repeater('phone in phones').column('name')

直放站部分元素相匹配,然后去找到 phone.name 元素(S)结合。它的包装元素恰好是同一

Repeater part matches the li element and then goes to find element(s) with phone.name binding. It's wrapping element happens to be the same li.

更改列部分 .column('片断')收益 P 元素,因为 phone.snippet 绑定发现的内部。

Changing column part to .column('snippet') returns p elements because phone.snippet binding is found inside of those.

相关的文档/例子在这里:的https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests

Relevant docs/examples here: https://github.com/angular/protractor/blob/master/docs/getting-started.md#writing-tests

这篇关于WebElement的量角器的getText直放站阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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