量角器getText()返回空结果 [英] protractor getText() returns empty result

查看:76
本文介绍了量角器getText()返回空结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些列表,通过ajax调用充满了行, 在它上面,我有一个itemCount跨度-显示我们有多少行. 在表被行填充后,itemCount跨度值将更新. 我想做的就是复制这个itemCount值,向其中添加一个新项目 列表,然后测试新的itemCount值是否大1 比旧的 我认为问题在于,当我从itemCount中获取第一个值时 跨度,它仍然是空的. 我尝试添加browser.waitForAngular();等,但该值仍然为空:

I have some list that gets filled with rows by ajax call, above it I have an itemCount span - to show how many rows we have. After the table is filled by rows, the itemCount span value is updated. what I try to do is to copy this itemCount value, to add a new item to the list and then to test that the new itemCount value is bigger by 1 than the old one. The problem, I think, is that when I take the first value from the itemCount span, it is still empty. I tried to add browser.waitForAngular();, etc, but the value is still empty:

element(by.id('itemsCount')).getText().then(function(text) {
    console.log('**********' + text);
});

我看到的只是:'**********'

what I see is just: '**********'

感谢您的帮助!

推荐答案

您可以尝试使用预期的条件.

var itemsCount    = element(by.id('itemsCount'));
var blank         = EC.textToBePresentInElementValue(itemsCount, '');
var itemsNotEmpty = EC.not(blank);

browser.wait(itemsNotEmpty, 5000, "✗ Failed to wait for the item count load").then(function() {
    itemsCount.getText().then(function(text) {
        console.log('**********' + text);
    });
});

基本上等到itemsCount不再为空,然后获取其文本.

Basically wait till the itemsCount isn't blank anymore then get it's text.

这篇关于量角器getText()返回空结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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