TypeError ERR_UNESCAPED_CHARACTERS on testing Vue project using Nightwatch

邮差的信 提交于 2021-01-29 14:18:07

问题


I have a problem trying to setup my Nightwatch environment with Vue CLI. At this point, I just want to make it work with Chrome (we'll see for Firefox soon) but when I run a simple test, It doesn't work.

Here is my test file:

module.exports = {
  'default e2e tests': browser => {
    browser
      .url("http://localhost:8080")
      .waitForElementVisible('#app', 5000)
      .assert.ok(true)
      .end()
  }
}

throwing the folowing error:

Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/28a21f6ed7009d54e70663e3ed407eb6/element/[object Object]/displayed": Request path contains unescaped cha
racters
    at new ClientRequest (_http_client.js:115:13)
    at Object.request (http.js:42:10)
    at HttpRequest.createHttpRequest (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\http\request.js:138:55)
    at HttpRequest.send (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\http\request.js:217:29)
    at Promise (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\transport\transport.js:193:15)
    at new Promise (<anonymous>)
    at Selenium2Protocol.sendProtocolAction (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\transport\transport.js:191:12)
    at Selenium2Protocol.runProtocolAction (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\transport\jsonwire.js:61:17)
    at Object.isElementDisplayed (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\transport\actions.js:54:10)
    at Selenium2Protocol.executeProtocolAction (C:\Users\john.doe\Desktop\Développement\App\vue\node_modules\nightwatch\lib\transport\transport.js:239:48)

I get this error when I provide a valid selector. I tried with a non existing selector and, in this case, I get a simple ... expected "visible" but got: "not found".

Here is my Nightwatch configuration file:

module.exports = {
  "src_folders": ["tests/e2e/specs"],
  "output_folder": "tests/e2e/reports",
  "page_objects_path": "tests/e2e/page-objects",
  "custom_assertions_path": "tests/e2e/custom-assertions",
  "custom_commands_path": "tests/e2e/custom-commands",
  "test_workers": {
    "enabled": true,
    "workers": "auto"
  },
  "selenium" : {
    "start_process" : true,
    "server_path" : "./node_modules/selenium-server-standalone-jar/jar/selenium-server-standalone-3.141.59.jar",
    "log_path" : "tests/e2e/logs",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "./node_modules/chromedriver/lib/chromedriver/chromedriver.exe"
    }
  },
  "test_settings" : {
    "default" : {
      "launch_url": 'https://www.google.com',
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "screenshots": {
        "enabled": true,
        "path": ""
      },
      "desiredCapabilities": {
        "browserName": "chrome",
        "javascriptEnabled": true,
        "acceptSslCerts": true
      }
    },
    "chrome": {
      "desiredCapabilities": {
        "browserName": "chrome",
        "chromeOptions": {
          "w3c": false
        }
      },
      "webdriver": {
        "use_legacy_jsonwire": false
  }
    },
    "firefox": {
      "desiredCapabilities": {
        "browserName": "firefox",
        "alwaysMatch": {
          "acceptInsecureCerts": true,
          "moz:firefoxOptions": {
            "args": []
          }
        }
      }
    }
  }
};

Any ideas of what could produce this error?

Let me know if I should provide other files from the node_modules folder for instance.


回答1:


Following the link of Estus Flask solved my problem:

Simply add this lines in the default configuration

"chromeOptions": {
    "w3c": false
}


来源:https://stackoverflow.com/questions/60378995/typeerror-err-unescaped-characters-on-testing-vue-project-using-nightwatch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!