【问题标题】:Nightwatch perform() not method after expectNightwatch perform() 不是期望后的方法
【发布时间】:2018-02-02 04:53:48
【问题描述】:

所以我相信在查看文档后这应该可以正常工作,但我希望运行一个期望已经完成的东西,但是目前它似乎没有工作。

工作

browser
  .url('https://www.google.co.uk/?')
  .expect.element('.Google Search').value.to.contain('Dashboard')
  .perform(function() {
    console.log('elementValue');
  })

坏了

browser
  .url('https://www.google.co.uk/?')
  .expect.element('.Google Search').value.to.contain('Dashboard')
  .perform(function() {
    console.log('elementValue');
  })


Error while running perform command: browser.moveToElement(...).doubleClick(...).setValue(...).click(...).expect.element(...).text.to.contain(...).perform is not a function

【问题讨论】:

  • 您帖子中的代码与错误中的描述不匹配。
  • 我删掉了很多不需要的api方法:)
  • 您帖子中应该被破坏的代码与您标记为工作的代码完全相同。
  • 哈哈是的,我会更新的。

标签: javascript selenium testing nightwatch.js


【解决方案1】:

当您使用 .expect 时,您会中断 Nightwatch 命令链并启动 Expect.js 链,因此在您调用 .expect.element('.Google Search') 后您会得到 Expect.js 对象而不是 Nightwatch browser 对象。

你需要的只是启动另一个链:

browser
  .url('https://www.google.co.uk/?')
  .expect.element('.Google Search').value.to.contain('Dashboard');

browser
  .perform(function() {
    console.log('elementValue');
  });

【讨论】:

    猜你喜欢
    • 2018-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 2020-05-20
    • 1970-01-01
    相关资源
    最近更新 更多