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

Error while running .executeScript() protocol action: Invalid Command #33

Open
lunayui opened this issue Jul 1, 2020 · 7 comments
Open

Comments

@lunayui
Copy link

lunayui commented Jul 1, 2020

I'm starting the BrowserStackLocal process via local.runner.js. and Nightwatch coverage code

But the build-in Jenkins is still failing and shows the error :

Response 500 POST https://hub-cloud.browserstack.com/wd/hub/execute (163ms)
{ value: { message: 'Invalid Command', error: [] } }
Error while running .executeScript() protocol action: Invalid Command
{ status: -1,
state: '',
value: { message: 'Invalid Command', error: [] },
errorStatus: '',
error: 'Invalid Command',
httpStatusCode: 500 }
Error: Error while running "execute" command: An error occurred while gathering coverage information
at
at process._tickCallback (internal/process/next_tick.js:189:7)
nightwatch.conf.js

globals_path: path.resolve(constants.NIGHTWATCH_CONFIGS_PATH, 'globals.js'), custom_commands_path: [ 'node_modules/nightwatch-coverage/commands' ],

global.js
`const path = require('path');
const { createCoverageReporter } = require('nightwatch-coverage');

const coverageReporter = createCoverageReporter({
coverageDirectory: path.join(process.cwd(), 'tests/colosseum/coverage'),
});

module.exports = {

coverageReporter,
abortOnAssertionFailure: true,
waitForConditionPollInterval: 500,
waitForConditionTimeout: 5000,

// executed after every test suite has ended
afterEach(browser,done) {
console.log("Nigthwach Browser " + browser.collectCoverage());
browser.collectCoverage(function () {
client.end(done);
});
},

//executed after the test run has finished

after(done) {
console.log("coverage report "+coverageReporter);
coverageReporter.save();
done();
}
}`

@RohanImmanuel
Copy link

Hi @lunayui, can you share the capabilities used for the test, while retracting your credentials.

I suspect that a JSONWire Protocol endpoint '/execute' was sent to what appears to a session using the newer W3C Webdriver Protocol, which expects the endpoint '/execute/sync' causing the error.

JSONWire Protocol: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidexecute
W3C Webdriver Protocol: https://www.w3.org/TR/webdriver/#execute-script

@lunayui
Copy link
Author

lunayui commented Jul 7, 2020

this is my nightwatch_config

nightwatch_config = {
src_folders: [source_path],
selenium: {
start_process: false,
host: 'hub-cloud.browserstack.com',
port: 443
},
globals_path: 'globals.js',
custom_commands_path: [
'node_modules/nightwatch-coverage/commands'
],
test_settings: {
default: {
// Used for the aynchronous browser.perform command
// 30 minutes
globals: {
asyncHookTimeout: 1800000
},
request_timeout_options: {
timeout: 600000
},
desiredCapabilities: {
project: BROWSERSTACK_PROJECT,
build: BROWSERSTACK_BUILD,
'browserstack.user': XXXXXX,
'browserstack.key': XXXXXX,
'browserstack.local': true,
'browserstack.networkLogs': false,
'browserstack.localIdentifier': BROWSERSTACK_BUILD,
browser: 'chrome',
browser_version: '83.0', // The latest version of chrome
os: 'Windows',
os_version: '10',
resolution: '2048x1536' // maximum resolution supported on browserstack.
}
}
}
};
// Code to copy seleniumhost/port into test settings
for (var i in nightwatch_config.test_settings) {
var config = nightwatch_config.test_settings[i];
config['selenium_host'] = nightwatch_config.selenium.host;
config['selenium_port'] = nightwatch_config.selenium.port;
config['desiredCapabilities'] = config['desiredCapabilities'] || {};
}

module.exports = nightwatch_config;

@abhi291096
Copy link

Hello, could you please try executing a test with Nightwatch v.1.3.4 and share the output? I executed a sample test and the command ".execute("document.readyState")"worked fine. Sample session: https://automate.browserstack.com/builds/fbb7c6463835662567d5feb4cd5215db4d26fbf7/sessions/354d6e134ef82a503bdf1342c1b8354043b23f6a?auth_token=20643b00980d140fa4175dab201dc56cf1ae46ba6d14fb7ef824cc9362d2af8e

@lunayui
Copy link
Author

lunayui commented Jul 9, 2020

Hello, I update Nightwatch v.1.3.4 and the latest but the error was change for :

[0;36m[Run All] Test Suite�[0m
10:46:27  �[0;35m====================�[0m
10:46:27  - �[0;36mConnecting to hub-cloud.browserstack.com on port 443...
10:46:27  �[0m
10:46:27  Connecting to BrowserStack Local...
10:46:27  ⚠ �[0;31mError connecting to hub-cloud.browserstack.com on port 443.�[0m
10:46:27  Nigthwach Browser Nightwatch API
10:46:27   �[1;31m  Response 500 POST https://hub-cloud.browserstack.com/wd/hub/execute (161ms)�[0m
10:46:27     { value: { message: �[32m'Invalid Command'�[39m, error: [] } }
10:46:27   �[1;31mError while running .executeScript() protocol action: Invalid Command
10:46:27  �[0m
10:46:27  { status: -1,
10:46:27    state: '',
10:46:27    value: { message: 'Invalid Command', error: [] },
10:46:27    errorStatus: '',
10:46:27    error: 'Invalid Command',
10:46:27    httpStatusCode: 500 }
10:46:27   �[1;31m�[0;31m  Error: Error while running "execute" command: An error occurred while gathering coverage information�[0m
10:46:27  �[0;90m       at <anonymous>�[0m�[0m
10:46:27  
10:46:27    See more info, video, & screenshots on Browserstack:
10:46:27    �[1;36mhttps://automate.browserstack.com/builds/undefined/sessions/undefined�[0m
10:46:27  �[1;31m_________________________________________________�[0m
10:46:27  
10:46:27  �[1;31mTEST FAILURE:�[0m �[0;31m2�[0m errors during execution; �[0;31m0�[0m tests failed, �[0;32m0�[0m passed �[0;90m(1.259s)�[0m
10:46:27  
10:46:27  �[0;31m ✖ runAll�[0m
10:46:27     �[0;31mError while running "execute" command: An error occurred while gathering coverage information�[0m
10:46:27  �[0;90mError: Error while running "execute" command: An error occurred while gathering coverage information
10:46:27      at <anonymous>�[0m

10:46:27  
10:46:27  �[0;31m  Error: An error occurred while retrieving a new session: "[browserstack.local] is set to true but local testing through BrowserStack is not connected."�[0m
10:46:27  �[0;90m       at endReadableNT (_stream_readable.js:1064:12)
10:46:27         at _combinedTickCallback (internal/process/next_tick.js:139:11)�[0m
10:46:27  
10:46:27  
10:46:27  �[0;31m  Error: Error while running "execute" command: An error occurred while gathering coverage information�[0m
10:46:27  �[0;90m       at <anonymous>�[0m

@shawnlobo96
Copy link

Hey @lunayui

I have reached out to you over email for further steps to get this working.

@kavyajain-qa
Copy link

Hi @shawnlobo96 I am stuck with a similar issue. Can you pls help me with the further steps too?
Thanks!

@browserstack-support
Copy link

browserstack-support commented Jul 8, 2022 via email

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

No branches or pull requests

6 participants