带有chromedriver的最新版本的Nightwatch在switchWindow中似乎已损坏

时间:2019-02-20 18:06:15

标签: selenium-chromedriver nightwatch.js

Chromedriver版本ChromeDriver 2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e)

测试网页

<!DOCTYPE HTML>
<html>
  <head>
    <title>Nightwatch.js Test</title>
  </head>
  <body>
    <h1>Nightwatch.js Test</h1>
    <input id="input" onkeyup="document.getElementById('result').textContent=this.value">
    <p id="result"></p>
    <a id="link" href="https://www.google.com/" target="_blank">test</a>
  </body>
</html>

示例测试

'use strict'

module.exports = {
  'sample test': function(browser) {
    browser
      .url(browser.launch_url)
      .waitForElementVisible('#link', 1000)
    browser
      .click('#link')
      .windowHandles((res) => {
        browser.assert.equal(res.value.length, 2, 'There are now two window handles')
        const [first, second] = res.value 
        browser.switchWindow(second)
        browser.pause(1000)
        browser.assert.urlEquals('https://www.google.com/')
      })
    browser.end()
  }
}

nightwatch @ latest

[Example] Test Suite
====================
Running:  sample test

✔ Element <#link> was visible after 65 milliseconds.
✔ Passed [equal]: There are now two window handles
 Error while running .switchToWindow() protocol action: invalid argument: 'name' must be a string

✖ Testing if the URL equals "https://www.google.com/" in 1000 ms. - expected "https://www.google.com/" but got: "http://localhost:8100/"
    at NightwatchAPI.browser.click.windowHandles (/Users/me/oss/nightwatch/test/specs/example.js:15:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7) 


FAILED: 1 assertions failed and  2 passed (2.469s)
   Error while running "urlEquals" command: Testing if the URL equals "https://www.avoxigenius.com/support/" in 1000 ms. - expected "https://www.avoxigenius.com/support/" but got: "http://localhost:8100/"
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
_________________________________________________

TEST FAILURE:  1 assertions failed, 2 passed. 3.506s

 ✖ example
 – sample test (2.469s)
   Testing if the URL equals "https://www.google.com/" in 1000 ms. - expected "https://www.google.com/" but got: "http://localhost:8100/"
       at NightwatchAPI.browser.click.windowHandles (/Users/me/oss/nightwatch/test/specs/example.js:15:24)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)

nightwatch@0.9.21

[Example] Test Suite
========================

Running:  sample test
 ✔ Element <#link> was visible after 29 milliseconds.
 ✔ Passed [equal]: There are now two window handles
 ✔ Testing if the URL equals "https://www.google.com/".

OK. 3 assertions passed. (3.487s)

这是守夜人的错误吗? chromedriver?我做错了什么吗?

0 个答案:

没有答案