如何从临时元素中获取文本

时间:2015-05-12 14:29:40

标签: javascript selenium text protractor end-to-end

我有HTML:

<div class="p-login-info" ng-show="loggedOut()">My text.</div>

在javascript中:

var e = element(by.className('p-login-info'));

e.getText()
.then(function(text){
    var logoutText = "You have been log out.";
    expect(text).toMatch(logoutText);
    console.log("============= "+text);
 });

我的控制台日志中没有任何内容。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

您可能希望使用textToBePresentInElement预期条件:

var EC = protractor.ExpectedConditions;

var e = element(by.className('p-login-info'));
browser.wait(EC.textToBePresentInElement(e, "You have been log out."), 5000);