【问题标题】:Expect element to not include text期望元素不包含文本
【发布时间】:2016-07-04 10:56:04
【问题描述】:

我可以写.assert.containsText('#output', 'find me') 让 NightWatch 在 div 中查找文本。

但是我如何告诉 NightWatch 不要在元素中找到文本呢?

更新了工作示例

  module.exports = {
    'Fetch data using the default JSON format': function (browser) {
      browser
      .url('http://localhost:5000')
        .waitForElementVisible('body', 1000)
        .clearValue('input[type=text]')
        .setValue('input[type=text]', 'http://localhost:5000/advertisers')
        .click('#fetchButton')
        .pause(1000)
        .assert.containsText('#output', 'MockAdvertiser')
        .expect.element('#output').text.to.not.contain('xml');

【问题讨论】:

    标签: node.js integration-testing nightwatch.js


    【解决方案1】:

    您可以使用 Expect API 代替 Assert API,如下所示:

    browser.expect.element('#output').text.to.not.equal('Do not find me');
    

    【讨论】:

      猜你喜欢
      • 2019-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多