【问题标题】:Get current URL using webdriver.io module使用 webdriver.io 模块获取当前 URL
【发布时间】:2019-07-19 05:07:25
【问题描述】:

我正在尝试使用以下代码和mocha.jswebdriver.io 测试我的应用程序是否在操作后正确重定向客户端。

it("Should redirect to correct URL.", function() {
 assert.equal(
   $("window").getAttribute("location"),      
  `http://localhost:8080/${path}`,
 );
});

但是我得到了错误:

无法在具有选择器“窗口”的元素上调用 getAttribute,因为 未找到元素

似乎窗口对象超出了webdriver 的选择器函数范围,但我在文档中看不到任何其他访问当前 URL 的方式。

【问题讨论】:

    标签: javascript node.js mocha.js webdriver-io


    【解决方案1】:

    找到带有 getUrl 函数的 v4 文档。

    it("Should redirect to correct URL.", function() {
     assert.equal(
       browser.getUrl(),      
      `http://localhost:8080/${path}`,
     );
    });
    

    【讨论】:

      猜你喜欢
      • 2018-03-23
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      • 2010-09-29
      相关资源
      最近更新 更多