Nightwatch.js导航在驱动程序中的行为方式不同

时间:2016-11-16 22:57:21

标签: nightwatch.js selenium-firefoxdriver selenium-iedriver

我想使用Nightwatch.js v.0.9.8进行E2E测试。

我的page object

module.exports = {
  url() {
    return path.join(this.api.launchUrl, 'Home/Index');
  }
};

我的测试:

module.exports = {
  'Sample 1'(client) {
    client.page.home()
      .navigate()
      .expect.element('body').to.be.present;
  },
  'Sample 2'(client) {
    client.page.home()
      .navigate()
      .expect.element('header').to.be.present;
    client.end();
  }
};

这在Chrome中完美无缺。

但是在Firefox(geckodriver 0.11.1 x64)中,Sample 2最终会在 http://localhost:3535/localhost:3535/Home/Index 上运行。

IE(IEDriverServer 2.53.1 x64)打开时出现一个对话框窗口: 无法找到路径'http:\ localhost:3535 \ Home \ Index'。确保路径或Internet地址正确无误。

我错过了一些明显的东西吗?

1 个答案:

答案 0 :(得分:1)

解决了 - 我的错误。问题是path.join(this.api.launchUrl, 'Home/Index')翻转斜杠。我用简单的字符串连接替换它,它可以正常工作。