【问题标题】:Nightwatch demo testNightwatch 演示测试
【发布时间】:2018-09-08 15:18:59
【问题描述】:

在网站上,nightwatch.js demo script已经失效,谷歌更改了搜索引擎结果页面html/css,所以之前的元素访问不起作用。尝试了一些使用元素和 xpath 的新方法,但我还没有找到解决方案。

module.exports = {
  'Demo test Google' : function (client) {
    client
      .url('http://www.google.com')
      .waitForElementVisible('body', 1000)
      .assert.title('Google')
      .assert.visible('input[type=text]')
      .setValue('input[type=text]', 'rembrandt van rijn')
      .waitForElementVisible('button[name=btnG]', 1000)
      .click('button[name=btnG]')
      .pause(1000)
      .assert.containsText('ol#rso li:first-child',
        'Rembrandt - Wikipedia')
      .end();
  }
};

知道要进行哪些更改才能完全运行测试并返回正确的结果吗?

【问题讨论】:

    标签: nightwatch.js


    【解决方案1】:

    这个对我有用。

    module.exports = {
        'Demo test Google' : function (client) {
          client
            .url('http://www.google.com')
            .waitForElementVisible('body', 1000)
            .assert.title(`Google`)
            .setValue('input[type=text]', ['rembrandt van rijn', client.keys.ENTER])
            .waitForElementVisible('input[name=btnK]', 1000)
            .click('input[name=btnK]')
            .pause(1000)
            .assert.containsText('div.srg > div:first-child',
              'Rembrandt - Wikipedia')
            .end();
        }
      };
    

    【讨论】:

      猜你喜欢
      • 2017-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-05
      • 1970-01-01
      • 2017-09-21
      • 2018-03-30
      相关资源
      最近更新 更多