由于空字符串,Nightwatch.js获取文本失败

时间:2015-10-12 14:40:03

标签: testing selector assert end-to-end nightwatch.js

我试图断言一个元素有一定的文本内容 Browser view and debug window Code and test output

但是测试总是失败并显示消息:

Failed [equal]: ('' == 'This is a title ') - Expected "This is a title " but got: ""

测试编写如下:

browser.getText('.ui-visible .caption-expanded b',
  function(result) {
    this.assert.equal(result.value, 'This is a title ');
  }
);

我也尝试过:

browser.expect.element('.ui-visible .caption-expanded b').text.to.equal('This is a title ');

两次尝试都以空字符串失败。我做错了吗?

1 个答案:

答案 0 :(得分:-1)

我认为你可以这样做.assert.containsText('name_of_your_element', 'This is a title')