Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrading from 0.9.x to 1.0.8 throws an error on waitForElementVisible #1864

Closed
gregoryduckworth opened this issue Aug 7, 2018 · 34 comments
Closed
Assignees
Labels

Comments

@gregoryduckworth
Copy link

gregoryduckworth commented Aug 7, 2018

My current scenario is that I am in the process of upgrading our test repository from 0.9 -> 1.0 however after following the wiki and getting the tests to start, some basic actions are performed correctly, such as navigating to the right page and providing feedback on that. However when the tests hit a waitForElementVisible the console reports the error Error while running .isElementDisplayed() protocol action: undefined.

The test steps are as follows:

var page = browser.page.testPage();

page.navigate();

page.waitForElementVisible('@testPanel');

Running the command with --verbose reports:

Running command: waitForElementVisible
   Request POST  /session/0d03be1f5a8319f7565664c337a0c881/elements
   { using: 'css selector', value: '#test-panel' }
   Response 200 POST /session/0d03be1f5a8319f7565664c337a0c881/elements (18ms)
   { sessionId: '0d03be1f5a8319f7565664c337a0c881',
     status: 0,
     value: [ { ELEMENT: '0.03954989682254517-1' } ] }
 Error while running .isElementDisplayed() protocol action: undefined
@gregoryduckworth gregoryduckworth changed the title Upgrading from 0.9 to 1.0 throws an error on waitForElementVisible Upgrading from 0.9.x to 1.0.8 throws an error on waitForElementVisible Aug 7, 2018
@beatfactor
Copy link
Member

Your config and platform details?

@gregoryduckworth
Copy link
Author

gregoryduckworth commented Aug 13, 2018

Platform is:

MAC OSX Sierra
node v8.11.3
npm v6.3.0
nightwatchjs v0.9.21

Config is:

var nightwatch_config = {
  src_folders:['tests'],
  page_objects_path:['pages'],
  globals_path:'global.js',
  custom_commands_path:[
    'commands',
  ],
  custom_assertions_path:[
    'assertions',
  ],

  selenium: {
    start_process : true,
    server_path : selenium.path,
    host: '127.0.0.1',
    port : 9515,
    cli_args: {
      'webdriver.chrome.driver': chromedriver.path,
    },
  },

  common_capabilities: {
    build: 'nightwatchjs',
    project: 'CD-Nightwatch',
  },

  test_workers: false,

  test_settings: {
    default: {
      default_path_prefix: '',
      screenshots: {
        enabled: true,
        on_failure: true,
        on_error: true,
        path: 'screenshots/local/failures',
      },
      skip_testcases_on_fail: false,
      browserName: 'chrome',
      desiredCapabilities: {
        chromeOptions: {
          args: [
            'incognito',
            'window-size=1366,768',
          ],
        },
      },
    },
  },
};

@beatfactor
Copy link
Member

And have you tried using chromedriver directly, without selenium? It's also strange that you have to set default_path_prefix: '', with selenium it's usually "/wd/hub". Which selenium version are you using?

@beatfactor beatfactor self-assigned this Aug 15, 2018
@beatfactor beatfactor added the bug label Aug 15, 2018
@beatfactor beatfactor added this to the Nightwatch v1.0 milestone Aug 15, 2018
@gregoryduckworth
Copy link
Author

gregoryduckworth commented Aug 22, 2018

Updated my config to (below) and still have the same issues

  • Removed the default_path_prefix: ''
var selenium = require('selenium-server-standalone-jar');
const chromedriver = require('chromedriver');

var nightwatch_config = {
  src_folders: ['tests'],
  page_objects_path: ['pages'],
  globals_path: 'global.js',
  custom_commands_path: [
    'commands',
    'node_modules/nightwatch-vrt/commands',
  ],
  custom_assertions_path:[
    'assertions',
    'node_modules/nightwatch-vrt/assertions',
  ],

  common_capabilities: {
    build: 'orbit-nightwatchjs',
    project: 'CD-Orbit-Nightwatch',
  },

  test_workers: false,

  test_settings: {
    default: {
      selenium: {
        start_process: true,
        server_path : selenium.path,
        cli_args: {
          'webdriver.chrome.driver': chromedriver.path,
        },
      },
      screenshots: {
        enabled: true,
        on_failure: true,
        on_error: true,
        path: 'screenshots/local/failures',
      },
      skip_testcases_on_fail: false,
      browserName: 'chrome',
      desiredCapabilities: {
        chromeOptions: {
          args: [
            'incognito',
            'window-size=1366,768',
          ],
        },
      },
    },
  },
};

// Code to support common capabilites
for (var i in nightwatch_config.test_settings) {
  var config = nightwatch_config.test_settings[i];
  config.desiredCapabilities = config.desiredCapabilities || {};
  for (var j in nightwatch_config.common_capabilities) {
    config.desiredCapabilities[j] = config.desiredCapabilities[j] || nightwatch_config.common_capabilities[j];
  }
}

module.exports = nightwatch_config;

@WilliamDASILVA
Copy link

@beatfactor

Getting the same error through BrowserStack only.

Error while running .isElementDisplayed() protocol action: undefined

Here's my config for Browserstack:

const selenium = {
  host: process.env.SELENIUM_HOST,
  port: process.env.SELENIUM_PORT
}

const nightwatchConfig = {
  src_folders: ['./test/e2e/tests'],
  output_folder: ['./test/e2e/reports'],
  selenium: {
    start_process: false,
    host: selenium.host,
    port: selenium.port
  },
  test_settings: {
    default: {
      desiredCapabilities: {
        'browserstack.user': process.env.BROWSERSTACK_USERNAME,
        'browserstack.key': process.env.BROWSERSTACK_ACCESS_KEY,
        'browserstack.local': true,
        'resolution': '1440x900',
        'os': 'Windows',
        'os_version': '10',
        'browserName': 'Chrome',
        'browser_version': '62.0',
        'browserstack.selenium_version': '3.11.0',
        'build': `${process.env.BROWSERSTACK_BUILD_NAME}`
      },
      skip_testcases_on_fail: false,
      screenshots: {
        enabled: true,
        path: './test/e2e/screenshots'
      }
    }
  }
}

// Code to copy seleniumhost/port into test settings
for (var i in nightwatchConfig.test_settings) {
  var config = nightwatchConfig.test_settings[i]
  config.webdriver = {
    webdriver_host: selenium.host,
    webdriver_port: selenium.port
  }
}

module.exports = nightwatchConfig

Browserstack settings:

browserName Chrome
acceptSslCerts true
resolution 1440x900
os Windows
os_version 10
browser_version 62.0
build 66108
name Global/Navbar
acceptSslCert true
browserstack.console errors
browserstack.appiumLogs false
browserstack.local true
browserstack.selenium_version 3.11.0

And this is my local config that I use before pushing. And in my local config, it works as expected.

nightwatch_config = {
  src_folders : ['./test/e2e/tests'],
  output_folder : ['./test/e2e/reports'],
  custom_commands_path : '',
  custom_assertions_path : '',
  page_objects_path : '',
  globals_path : '',

  selenium: {
    start_process : true,
    server_path : './test/e2e/bin/selenium-server-standalone-3.12.0.jar',
    log_path : '',
    port : 4444,
    cli_args : {
      'webdriver.chrome.driver': './test/e2e/bin/chromedriver',
      'webdriver.gecko.driver': './test/e2e/bin/geckodriver'
    }
  },
  test_settings : {
    default : {
      launch_url : 'http://.../offers',
      webdriver: {
        webdriver_host: 'localhost',
        webdriver_port: 4444
      },
      silent: true,
      screenshots : {
        enabled : true,
        path : './test/e2e/screenshots'
      },
      globals: {
        devServerURL: 'http://.../offers'
      },
      desiredCapabilities: {
        browserName: 'chrome',
        javascriptEnabled: true,
        acceptSslCerts: true,
        elementScrollBehavior: 1
      }
    },

    chrome : {
      desiredCapabilities: {
        browserName: 'chrome',
        javascriptEnabled: true,
        acceptSslCerts: true,
        elementScrollBehavior: 1
      }
    },
    firefox: {
      desiredCapabilities: {
        browserName: 'firefox',
        javascriptEnabled: true,
        acceptSslCerts: true,
        marionnette: true,
        elementScrollBehavior: 1
      }
    }
  }
};

module.exports = nightwatch_config

@beatfactor
Copy link
Member

@WilliamDASILVA do you have a verbose log output as well?

@WilliamDASILVA
Copy link

@beatfactor

I do but it does not provide extra informations about the issue.

BrowserStack: Connecting local
BrowserStack: Connected. Now testing...

[Global/Navbar] Test Suite
==========================
   Request POST http://hub-cloud.browserstack.com:4444 /wd/hub/session  
   { desiredCapabilities: 
      { browserName: 'Chrome',
        acceptSslCerts: true,
        platform: 'ANY',
        'browserstack.user': 'USERNAME=',
        'browserstack.key': 'KEY=',
        'browserstack.local': true,
        resolution: '1440x900',
        os: 'Windows',
        os_version: '10',
        browser_version: '62.0',
        'browserstack.selenium_version': '3.11.0',
        build: 'undefined',
        name: 'Global/Navbar' } }
   Response 200 POST http://hub-cloud.browserstack.com:4444/wd/hub/session (6306ms)
   { status: 0,
     sessionId: 'SESSIONID=',
     value: 
      { applicationCacheEnabled: false,
        rotatable: false,
        mobileEmulationEnabled: false,
        networkConnectionEnabled: false,
        chrome: 
         { chromedriverVersion: '2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)',
           userDataDir: 'C:\\Windows\\proxy\\scoped_dir8760_2579' },
        takesHeapSnapshot: true,
        pageLoadStrategy: 'normal',
        databaseEnabled: false,
        handlesAlerts: true,
        hasTouchScreen: false,
        version: '62.0.3202.62',
        platform: 'Windows NT',
        browserConnectionEnabled: false,
        nativeEvents: true,
        acceptSslCerts: true,
        locationContextEnabled: true,
        webStorageEnabled: true,
        browserName: 'chrome',
        takesScreenshot: true,
        javascriptEnabled: true,
        cssSelectorsEnabled: true,
        setWindowRect: true,
        unexpectedAlertBehaviour: '',
        'webdriver.remote.sessionid': 'SESSIONID=' } }
 Received session with ID: SESSIONID=

Running:  launch


 → Running command: resizeWindow

 → Running command: windowSize
   Request POST http://hub-cloud.browserstack.com:4444 /wd/hub/session/SESSIONID=/window/current/size  
   { width: 1024, height: 900 }
   Response 200 POST http://hub-cloud.browserstack.com:4444/wd/hub/session/SESSIONID=/window/current/size (1171ms)
   { sessionId: 'SESSIONID=',
     status: 0,
     value: null }
 → Completed command windowSize (1173ms)

 → Running command: url
   Request POST http://hub-cloud.browserstack.com:4444 /wd/hub/session/SESSIONID=/url  
   { url: 'http://0.0.0.0:8080/?token=goodDispatcherToken' }
   Response 200 POST http://hub-cloud.browserstack.com:4444/wd/hub/session/SESSIONID=/url (8974ms)
   { sessionId: 'SESSIONID=',
     status: 0,
     value: null }
 → Completed command url (8975ms)

 → Running command: waitForElementVisible
   Request POST http://hub-cloud.browserstack.com:4444 /wd/hub/session/SESSIONID=/elements  
   { using: 'css selector', value: 'body' }
   Response 200 POST http://hub-cloud.browserstack.com:4444/wd/hub/session/SESSIONID=/elements (129ms)
   { sessionId: 'SESSIONID=',
     status: 0,
     value: [ { ELEMENT: '0.5922374834070097-1' } ] }
 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 → Completed command waitForElementVisible (3156ms)

 → Running command: waitForElementPresent
   Request POST http://hub-cloud.browserstack.com:4444 /wd/hub/session/SESSIONID=/elements  
   { using: 'css selector', value: 'div#app' }
✖ Timed out while waiting for element <body> to be visible for 3000 milliseconds. - expected "visible" but got: "not visible"

@gmcdev
Copy link

gmcdev commented Aug 30, 2018

We are coming across similar problems with waitForElementVisible() in Chrome environments. Everything was working fine until earlier this week.

We have scaled back to the sample Browserstack test, here: https://www.browserstack.com/automate/nightwatch#sample-test

Same problem in Chrome v60-69 (letting Browserstack pick Chromedriver).

Works fine in Firefox on Browserstack.

Works intermittently when running Selenium/Chromedriver/Chrome.app installed locally on OSX.

{  
   "selenium":{  
      "start_process":false,
      "host":"hub-cloud.browserstack.com",
      "port":80
   },
   "test_settings":{  
      "default":{  
         "selenium_host":"hub-cloud.browserstack.com",
         "selenium_port":80,
         "desiredCapabilities":{  
            "screenshots":{  
               "enabled":true,
               "on_failure":true,
               "on_error":true,
               "path":"./reports/screenshots"
            },
            "resolution":"1280x1024",
            "browserstack.user":"XXXX",
            "browserstack.key":"XXXX",
            "browserstack.local":true
         }
      },
      "osx_hs_chrome":{  
         "desiredCapabilities":{  
            "os":"OS X",
            "os_version":"High Sierra",
            "browser":"Chrome",
            "browser_version":"68.0",
            "chromeOptions":{  
               "args":[  
                  "auto-open-devtools-for-tabs"
               ]
            }
         }
      },
      "osx_hs_firefox":{  
         "desiredCapabilities":{  
            "os":"OS X",
            "os_version":"High Sierra",
            "browser":"Firefox",
            "browser_version":"61.0"
         }
      }
   }
}

And the result:

[Main Test] Test Suite
======================
Running:  Google's Search Functionality

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

 Error while running .isElementDisplayed() protocol action: undefined

✖ Timed out while waiting for element <body> to be visible for 1000 milliseconds. - expected "visible" but got: "not visible"
    at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:5:8)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

   An error occurred while running .setValue() command on <input[type=text]>: Error: First argument passed to .elementIdValue() should be a web element ID string. Received object.
      at Function.validateElementId (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:36:19)
      at ProtocolActions.elementIdValue (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:945:25)
      at transport.locateElement.then.result (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api-loader/element-command.js:106:54)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
✖ Testing if the page title equals "BrowserStack - Google Search". - expected "BrowserStack - Google Search" but got: "Google"
    at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:8:15)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)


FAILED: 2 assertions failed and  1 errors (3.253s)
   Testing if the page title equals "BrowserStack - Google Search". - expected "BrowserStack - Google Search" but got: "Google"
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
_________________________________________________

TEST FAILURE: 1 error during execution 2 assertions failed, 0 passed. 24.233s

 ✖ main.test
 – Google's Search Functionality (3.253s)
   Timed out while waiting for element <body> to be visible for 1000 milliseconds. - expected "visible" but got: "not visible"
       at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:5:8)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
   Testing if the page title equals "BrowserStack - Google Search". - expected "BrowserStack - Google Search" but got: "Google"
       at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:8:15)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)

  An error occurred while running .setValue() command on <input[type=text]>: Error: First argument passed to .elementIdValue() should be a web element ID string. Received object.
      at Function.validateElementId (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:36:19)
      at ProtocolActions.elementIdValue (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:945:25)
      at transport.locateElement.then.result (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api-loader/element-command.js:106:54)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)

I'm not convinced this is a Nightwatch issue, so apologies for posting here, if it's not. We'll keep digging tomorrow.

@beatfactor
Copy link
Member

@gmcdev which nightwatch version are you using?

@gmcdev
Copy link

gmcdev commented Aug 30, 2018

@beatfactor, We were on 1.0.6 - upped to 1.0.10 while investigating.

@Everlag
Copy link

Everlag commented Sep 7, 2018

We're also running into this on Saucelabs. Chrome is fine while firefox, ie, and safari all fail with this error.

1.0.6 and 1.0.10 both demonstrate this issue.This is a new adoption of nightwatch so we don't have a previous good version.

const seleniumServer = require("selenium-server");
const chromedriver = require("chromedriver");
const geckodriver = require("geckodriver");

module.exports = {
  src_folders: ['tests/'],
  "selenium": {
    "start_process": true,
    "server_path": seleniumServer.path,
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {
      "webdriver.chrome.driver": chromedriver.path,
      "webdriver.gecko.driver": geckodriver.path,
    }
  },
  test_settings: {
    "default": {
      "selenium_port": 80,
      "selenium_host": "ondemand.saucelabs.com",
      "silent": true,
      "screenshots": {
        "enabled": false,
      },
      "username": "${SAUCE_USERNAME}",
      "access_key": "${SAUCE_ACCESS_KEY}",
    },
    // Local chrome(chromedriver)
    "chrome": {
      "desiredCapabilities": {
        "browserName": "chrome",
      },
      "chromeOptions": {
        "args" : ["--no-sandbox"]
      }
    },
    // Local firefox(geckodriver)
    "firefox": {
      "desiredCapabilities": {
        "browserName": "firefox",
      }
    },
    "internet_explorer_11": {
      "desiredCapabilities": {
        "platform": "Windows 10",
        "browserName": "internet explorer",
        "version": "11"
      }
    },
    "safari_11": {
      "desiredCapabilities": {
        "platform": "macOS 10.12",
        "browserName": "safari",
        "version": "11.0"
      }
    }
  }
}

@beatfactor
Copy link
Member

@Everlag Ok, could you also post a verbose log output with a failed test? Thanks.

@beatfactor beatfactor reopened this Sep 7, 2018
@beatfactor
Copy link
Member

Please try with v1.0.11.

@Everlag
Copy link

Everlag commented Sep 7, 2018

Tried with v1.0.11, same issue.

Chrome tests still works fine.

Relevant snippet from code

browser
      .url(documentPath())
      .waitForElementVisible('body')

Verbose(some redacted with ...; nothing that should impact the correctness)

 Starting Selenium Server on port 80...
 Selenium Server process closed.
 Selenium Server up and running on port 80 with pid: 10036 (978ms).

[Smoke] Test Suite
==================
   Request POST http://ondemand.saucelabs.com:80 /wd/hub/session  
   { desiredCapabilities: 
      { browserName: 'firefox',
        acceptSslCerts: true,
        platform: 'ANY',
        name: 'Smoke' } }
   Response 200 POST http://ondemand.saucelabs.com:80/wd/hub/session (11885ms)
   { status: 0,
     state: null,
     value: 
      { rotatable: false,
        browserVersion: '62.0',
        takesScreenshot: true,
        cssSelectorsEnabled: true,
        timeouts: { pageLoad: 300000, implicit: 0, script: 30000 },
        'moz:headless': false,
        'moz:useNonSpecCompliantPointerOrigin': false,
        'moz:webdriverClick': true,
        'moz:profile': 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\rust_mozprofile.T1quY5CIrYCT',
        acceptInsecureCerts: false,
        browserName: 'firefox',
        'webdriver.remote.sessionid': '3e746f1af36341fea58e83a5ac182a67',
        hasMetadata: true,
        platform: 'ANY',
        javascriptEnabled: true,
        platformVersion: '6.1',
        'moz:processID': 1712,
        pageLoadStrategy: 'normal',
        platformName: 'windows_nt',
        'moz:accessibilityChecks': false },
     sessionId: '3e746f1af36341fea58e83a5ac182a67' }
 Received session with ID: 3e746f1af36341fea58e83a5ac182a67

Running:  vanilla


 → Running command: url
   Request POST http://ondemand.saucelabs.com:80 /wd/hub/session/3e746f1af36341fea58e83a5ac182a67/url  
   { ... }
   Response 200 POST http://ondemand.saucelabs.com:80/wd/hub/session/3e746f1af36341fea58e83a5ac182a67/url (3090ms)
   { status: 0,
     sessionId: '3e746f1af36341fea58e83a5ac182a67',
     value: null,
     state: 'success' }
 → Completed command url (3092ms)

 → Running command: waitForElementVisible
   Request POST http://ondemand.saucelabs.com:80 /wd/hub/session/3e746f1af36341fea58e83a5ac182a67/elements  
   { using: 'css selector', value: 'body' }
   Response 200 POST http://ondemand.saucelabs.com:80/wd/hub/session/3e746f1af36341fea58e83a5ac182a67/elements (552ms)
   { status: 0,
     sessionId: '3e746f1af36341fea58e83a5ac182a67',
     value: [ { ELEMENT: '0' } ],
     state: 'success' }
 Error while running .isElementDisplayed() protocol action: TypeError: Error while trying to create HTTP request for "/wd/hub/session/3e746f1af36341fea58e83a5ac182a67/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)
    at HttpRequest.createHttpRequest (/usr/local/lib/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/usr/local/lib/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/usr/local/lib/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:436:48)

 Error while running .isElementDisplayed() protocol action: TypeError: Error while trying to create HTTP request for "/wd/hub/session/3e746f1af36341fea58e83a5ac182a67/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)
    at HttpRequest.createHttpRequest (/usr/local/lib/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/usr/local/lib/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/usr/local/lib/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/usr/local/lib/node_modules/nightwatch/lib/transport/transport.js:436:48)

@gmcdev
Copy link

gmcdev commented Sep 7, 2018

NW 1.0.11, Chrome on BrowserStack, running the sample BrowserStack test:

module.exports = {
  'Google\'s Search Functionality' : function (browser) {
    browser
      .url('https://www.google.com/ncr')
      .waitForElementVisible('body', 1000)
      .setValue('input[type=text]', 'BrowserStack\n')
      .pause(1000)
      .assert.title('BrowserStack - Google Search')
      .end();
  }
};

Result:

[Main Test] Test Suite
======================
Running:  Google's Search Functionality

 Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/25cc17064a0ecfc30887bf3cc6565cc7253020f3/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)
    at HttpRequest.createHttpRequest (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:436:48)

 Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/25cc17064a0ecfc30887bf3cc6565cc7253020f3/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)
    at HttpRequest.createHttpRequest (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:436:48)

 Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/25cc17064a0ecfc30887bf3cc6565cc7253020f3/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)
    at HttpRequest.createHttpRequest (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/transport/transport.js:436:48)

✖ Timed out while waiting for element <body> to be visible for 1000 milliseconds. - expected "visible" but got: "not visible"
    at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:5:8)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)

   An error occurred while running .setValue() command on <input[type=text]>: Error: First argument passed to .elementIdValue() should be a web element ID string. Received object.
      at Function.validateElementId (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:36:19)
      at ProtocolActions.elementIdValue (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:951:25)
      at transport.locateElement.then.result (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api-loader/element-command.js:106:54)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
✖ Testing if the page title equals "BrowserStack - Google Search" in 1000 ms. - expected "BrowserStack - Google Search" but got: "Google"
    at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:8:15)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:118:7)


FAILED: 2 assertions failed and  1 errors (4.677s)
   Testing if the page title equals "BrowserStack - Google Search" in 1000 ms. - expected "BrowserStack - Google Search" but got: "Google"
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
_________________________________________________

TEST FAILURE: 1 error during execution 2 assertions failed, 0 passed. 21.689s

 ✖ main.test
 – Google's Search Functionality (4.677s)
   Timed out while waiting for element <body> to be visible for 1000 milliseconds. - expected "visible" but got: "not visible"
       at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:5:8)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
   Testing if the page title equals "BrowserStack - Google Search" in 1000 ms. - expected "BrowserStack - Google Search" but got: "Google"
       at Object.Google's Search Functionality (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/tests/active/containers/raw-source/wc-netflix-text/main.test.js:8:15)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)

  An error occurred while running .setValue() command on <input[type=text]>: Error: First argument passed to .elementIdValue() should be a web element ID string. Received object.
      at Function.validateElementId (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:36:19)
      at ProtocolActions.elementIdValue (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api/protocol.js:951:25)
      at transport.locateElement.then.result (/Users/greg.connell/Documents/_NETFLIX/da-testing-framework/node_modules/nightwatch/lib/api-loader/element-command.js:106:54)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)
       at <anonymous>
       at process._tickCallback (internal/process/next_tick.js:118:7)

In Firefox 61, the waitForElementVisible part works...but the setValue newline trick doesn't submit the form, so the test fails.

@beatfactor
Copy link
Member

beatfactor commented Sep 10, 2018

@gmcdev what is your browserstack config?

@gregoryduckworth
Copy link
Author

Upgraded to 1.0.11 and get the same error as @gmcdev

Error while running .isElementDisplayed() protocol action: TypeError: Error while trying to create HTTP request for "/wd/hub/session/5ab16569d0bc7027d6748c9b90d2c82f/element/[object Object]/displayed": Request path contains unescaped characters

@gmcdev
Copy link

gmcdev commented Sep 10, 2018

@beatfactor same config as my previous post -- thanks for looking into it!

@beatfactor
Copy link
Member

@gmcdev the issue is that you're setting browser as the capabilities name, it should be browserName.

@gmcdev
Copy link

gmcdev commented Sep 10, 2018

@beatfactor - ouch, that is embarrassing, thanks for the catch. Changing it to browserName solves the waitForElementVisible problem that we're having.

It appears BrowserStack needs to update their docs: https://www.browserstack.com/automate/nightwatch

We will follow-up there. Thanks again~

@beatfactor
Copy link
Member

@gmcdev no problem. I should add browser as an alias as well, or at least show an error message.

@beatfactor
Copy link
Member

I'm closing this, if anyone still experiences this issue, please re-open.

@gregoryduckworth
Copy link
Author

Thanks @beatfactor, I had to move browserName to inside the desiredCapabilties section rather than at the same level.

@irobayna
Copy link

@beatfactor The problem still exists on 1.0.11while using the Edge browser (using BrowserStack) BTW, Chrome and Firefox work fine on latest. Also, if revert to 0.9.x everything works including Edge

Connecting local
Connected. Now testing...

[Signon Owner Test] Test Suite
==============================
   Request POST http://hub-cloud.browserstack.com /wd/hub/session
   { desiredCapabilities:
      { browserName: 'Edge',
        acceptSslCerts: true,
        platform: 'ANY',
        'browserstack.user': 'khoyzvbigetkfxr1',
        'browserstack.key': 'unHo2zCaNHPVEXVyHUCx',
        'browserstack.local': true,
        'browserstack.debug': true,
        build: '1.1',
        name: 'Signon Owner Test' } }
   Response 200 POST http://hub-cloud.browserstack.com/wd/hub/session (4980ms)
   { state: null,
     sessionId: 'a495917005efc0660569a11a1d2f713969d426db',
     value:
      { applicationCacheEnabled: true,
        InPrivate: false,
        pageLoadStrategy: 'normal',
        platform: 'ANY',
        acceptSslCerts: true,
        'webdriver.remote.sessionid': 'a495917005efc0660569a11a1d2f713969d426db',
        browserVersion: '41.16299.15.0',
        platformVersion: '10',
        locationContextEnabled: true,
        webStorageEnabled: true,
        browserName: 'MicrosoftEdge',
        takesScreenshot: true,
        takesElementScreenshot: true,
        javascriptEnabled: true,
        platformName: 'windows',
        cssSelectorsEnabled: true },
     status: 0 }
 Received session with ID: a495917005efc0660569a11a1d2f713969d426db
...

 → Running command: waitForElementVisible
   Request POST http://hub-cloud.browserstack.com /wd/hub/session/c96c91ccacb1532041fbf7834703fb5a45d38d36/elements
   { using: 'css selector', value: 'body' }
   Response 200 POST http://hub-cloud.browserstack.com/wd/hub/session/c96c91ccacb1532041fbf7834703fb5a45d38d36/elements (431ms)
   { state: 'success',
     sessionId: 'c96c91ccacb1532041fbf7834703fb5a45d38d36',
     value: [ { ELEMENT: '0' } ],
     status: 0 }
 Error while running .isElementDisplayed() protocol action: TypeError: Error while trying to create HTTP request for "/wd/hub/session/c96c91ccacb1532041fbf7834703fb5a45d38d36/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:127:13)
    at Object.request (http.js:38:10)

The probem seems to be on the URL, see the [object object]

/wd/hub/session/a495917005efc0660569a11a1d2f713969d426db/element/[object Object]/displayed

@Everlag
Copy link

Everlag commented Sep 11, 2018

Still running into this issue, I've had browserName in desiredCapabilities since the start.

@beatfactor
Copy link
Member

@irobayna thanks, I'll look into it.

@beatfactor beatfactor reopened this Sep 12, 2018
@Everlag
Copy link

Everlag commented Sep 13, 2018

Switched from saucelabs to browserstack for unrelated reasons, continuing to experience this issue. However, we're now seeing firefox successfully complete and edge fail; firefox, previously, did not work with saucelabs. The URL problem is the same as @irobayna.

@WilliamDASILVA
Copy link

For the record, my specific issue was resolved in the v1.0.11.

@Everlag
Copy link

Everlag commented Sep 19, 2018

Any update on this? We're blocked on bringing our integration tests to CI.

@beatfactor
Copy link
Member

@Everlag There will be a fix for edge posted this week.

@SteffenL
Copy link

Similar problem in v1.0.11 when testing on a mobile device on BrowserStack:

 Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/485a2f033ac0fb51682c24a76e16aecb025bd995/element/[object Object]/displayed": Request path contains unescaped characters
    at new ClientRequest (_http_client.js:114:13)
    at Object.request (http.js:41:10)
    at HttpRequest.createHttpRequest (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/http/request.js:112:55)
    at HttpRequest.send (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/http/request.js:191:29)
    at Promise (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/transport/transport.js:193:15)
    at new Promise (<anonymous>)
    at SeleniumProtocol.sendProtocolAction (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/transport/transport.js:191:12)
    at SeleniumProtocol.runProtocolAction (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/transport/jsonwire.js:51:17)
    at Object.target.(anonymous function).definition [as isElementDisplayed] (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/transport/actions.js:46:33)
    at SeleniumProtocol.executeProtocolAction (/home/travis/build/InveniaAS/ensafer-client-integration-test/node_modules/nightwatch/lib/transport/transport.js:436:48)
    desiredCapabilities: {
        os_version: "4.4",
        device: "Samsung Galaxy Tab 4",
        real_mobile: true
    }

@Everlag
Copy link

Everlag commented Oct 4, 2018

@beatfactor What's the status on that fix and is it expected to potentially address other issues?

@alexander-svendsen
Copy link

All our tests in browserstack that dosn't use chrome or firefox as the browser now fails in the same way as described above. ETA on the fix you are working on would be greatly appreciated @beatfactor 😄

@matiasbontempo
Copy link

@beatfactor I'm experiencing this same issue.

Using BrowserStack, tests work fine in Firefox and (sometimes) Chrome, but IE, Edge, Safari and mobile testing break when trying to perform any selection. This is the error messages I get:

Error while running .isElementDisplayed() protocol action: TypeError [ERR_UNESCAPED_CHARACTERS]: Error while trying to create HTTP request for "/wd/hub/session/2fdb031029d1bc253c7fe09cd0497b0b68b22b95/element/[object Object]/displayed": Request path contains unescaped characters
Error while running .locateSingleElement() protocol action: no such element: Unable to locate element: {"method":"css selector","selector":"input[type=text]"}

I changed browser to browserName as detailed above, but same result.

Let me know if there's any other information I can provide you.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants