My nightwatch.js tests not runs in Chrome headless of CentOS - automation

I run nightwatch.js tests using Nightwatch version 1.0.18 and It's working in windows environment but when I run it in centOS after installment of Xvfb I found below error.
Error while running .navigateTo() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
Error while running .locateMultipleElements() protocol action: invalid session id
Here is my nightwatch.json file code:
{
"src_folders": [
"./tests"
],
"output_folder": "./reports",
"custom_commands_path": "./custom_commands",
"custom_assertions_path": "",
"test_workers": false,
"webdriver": {
"start_process": true
},
"test_settings": {
"default": {
"webdriver": {
"port": 9515,
"server_path": "./node_modules/chromedriver/lib/chromedriver/chromedriver",
"cli_args": [
"--log",
"debug"
]
},
"skip_testcases_on_fail": true,
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true,
"chromeOptions": {
"args": [
"headless",
"no-sandbox",
"disable-gpu"
]
}
}
}
}
}
am I missing something to run my tests in the centOS environment because it is running in the windows environment?

I had the same issue with Nightwatchjs and the npm chomedriver setup.
Background:
Everything was working until I just recently updated Chromium on my system. In addition to the errors in the original post, verbose logging also showed:
{
message: 'unknown error: Chrome failed to start: exited abnormally',
error: [
"(unknown error: DevToolsActivePort file doesn't exist)",
'(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)',
'(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64)'
],
}
After downloading the standalone chromedriver (2.46.628388) to match my Chromium version (72.0.3626.69) it was still showing the same errors.
Solution:
I ended up downloading an older version of Chromium (71.0.3578.127) and setting chromeOptions.binary to the new path of the chromium 71 binary. I also had to include 'no-sandbox' with chromeOptions.args.
Here is the snippet from the site mentioned above:
Downloading old builds of Chrome / Chromium
Let's say you want a build of Chrome 44 for debugging purposes. Google does not offer old builds as they do not have up-to-date security fixes.
However, you can get a build of Chromium 44.x which should mostly match the stable release. Here's how you find it:
Look in https://googlechromereleases.blogspot.com/search/label/Stable%20updates for the last time "44." was mentioned.
Loop up that version history ("44.0.2403.157") in the Position Lookup
In this case it returns a base position of "330231". This is the commit of where the 44 release was branched, back in May 2015.*
Open the continuous builds archive
Click through on your platform (Linux/Mac/Win)
Paste "330231" into the filter field at the top and wait for all the results to XHR in.
Eventually I get a perfect hit: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/330231/
Sometimes you may have to decrement the commit number until you find one.
Download and run!

Upgrading to the latest version of chromedriver solved the issue for me. You can find the latest version here; https://www.npmjs.com/package/chromedriver

In my situation, when that error occurs:
Error while running .navigateTo() protocol action: invalid session id
I added the following code into .travis.yml:
addons:
chrome: stable

Related

why It show me This version of ChromeDriver only supports Chrome version 104?

when I use wdio for e2e tests, I got an exception.But my chromedriver is 106.0.1.
[0-1] 2022-10-24T10:58:18.928Z ERROR webdriver: Request failed with status 500 due to session not created: session not created: This version of ChromeDriver only supports Chrome version 104
[0-1] Current browser version is 106.0.5249.119 with binary path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
but when I check chromedriver:
chromedriver -v
ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249#{#569})
I has been tried all those methods:
SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81.
But I still got same exception.please help me.
My configureation:
module.exports.config = {
runner: "local",
path: "/wd/hub",
specs: ["./test/specs/*.js"],
maxInstances: 1,
capabilities: [
{
pageLoadStrategy: "none",
maxInstances: 1,
//
browserName: "chrome",
"goog:chromeOptions": {
excludeSwitches: ["enable-automation"],
},
},
],
logLevel: "warn",
bail: 0,
baseUrl: "http://localhost:3333",
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
services: ["chromedriver"],
framework: "mocha",
reporters: ["spec"],
}
I resolve this question by configure path.
services: [
[
"chromedriver",
{
chromedriverCustomPath: "/usr/local/bin/chromedriver",
},
],
],
I solved this problem by configuring the path. But I don't think this is a good method, because it means that any participant who uses this testing function needs to set the chromedriver in this path.
In fact, another project with the same npm version and my other configuration can run normally without configuring the path. This is really strange! This shows that my local chromedriver has no problems and can run directly.

How to use Edge Chromium webdriver "unknown error: cannot find MSEdge binary"

I am trying to use the WebDriver for the Edge Chromium version with PostMan, but I cannot make it work.
WebDriver Download: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Doc: https://learn.microsoft.com/en-us/microsoft-edge/webdriver
I try to add the Edge Chromium and Webdriver in the system PATH environment variable and no difference. I think the selenium implementation in java work with the Edge Chromium Webdriver
msedgedriver.exe --port 9515
POST localhost:9515/session
{
"capabilities":{
"firstMatch":[
{
}
],
"alwaysMatch":{
"browserName":"MicrosoftEdge",
"platformName":"windows",
"goog:chromeOptions":{
"extensions":[
],
"args":[
]
}
}
},
"desiredCapabilities":{
"browserName":"MicrosoftEdge",
"version":"",
"platform":"WINDOWS",
"goog:chromeOptions":{
"extensions":[
],
"args":[
]
}
}
}
{
"value": {
"error": "unknown error",
"message": "unknown error: cannot find MSEdge binary",
"stacktrace":
"Backtrace:\n\tOrdinal0 [0x00007FF6678D7C52+1932370]\n\tOrdinal0
[0x00007FF66783CDA2+1297826]\n\tOrdinal0
[0x00007FF6677A0A51+658001]\n\tOrdinal0 [0x00007FF667710F1F+69407]\n\tOrdinal0
[0x00007FF66770EF02+61186]\n\tOrdinal0 [0x00007FF667737DBD+228797]\n\tOrdinal0
[0x00007FF6677351AF+217519]\n\tOrdinal0 [0x00007FF66771706F+94319]\n\tOrdinal0
[0x00007FF66771822E+98862]\n\tOrdinal0
[0x00007FF66785B531+1422641]\n\tGetHandleVerifier
[0x00007FF6679991E9+656297]\n\tGetHandleVerifier
[0x00007FF667998F81+655681]\n\tGetHandleVerifier
[0x00007FF6679A104C+688652]\n\tGetHandleVerifier
[0x00007FF6679999C3+658307]\n\tOrdinal0
[0x00007FF66785177E+1382270]\n\tOrdinal0
[0x00007FF66785D9D6+1432022]\n\tOrdinal0
[0x00007FF66785C84D+1427533]\n\tBaseThreadInitThunk
[0x00007FF909056FD4+20]\n\tRtlUserThreadStart [0x00007FF90AB5B1F1+33]\n"
}
}
The WebDriver should open and be able to execute other commands
I suggest you to refer steps below may help to solve the issue.
(1) First try to set the environment variable for your Edge (chromium) application.
(2) Try to open PowerShell window and try to launch the Edge web driver.
(3) Launch the Postman app and try to use http://localhost:9515/session as POST request.
(4) Add code below as body of the request.
{
"desiredCapabilities": {
"nativeEvents": false,
"browserName": "edg",
"version": "",
"platform": "ANY",
"javascriptEnabled": true,
"takesScreenshot": true,
"handlesAlerts": true,
"databaseEnabled": true,
"locationContextEnabled": true,
"applicationCacheEnabled": false,
"browserConnectionEnabled": true,
"cssSelectorsEnabled": true,
"webStorageEnabled": true,
"rotatable": true
}
}
(5) Try to send the request.
Reference:
SeleniumHQ/selenium
Notes:
Your environment variable should properly set and referenced to your
Edge (chromium) correctly.
Use the supported version of Edge web driver with your Edge
(chromium) browser.
This should really be a comment and not a full answer (ridiculous reputation system tbh); Anyway, to add to Deepak-MSFT's answer - after adding the environment variables be sure to restart your IDE.
I added my MSEdge directory to the PATH and Eclipse would still complain. Everything worked after I closed and re-opened Eclipse.
Also check if you are pointing to MSEdge.exe or the directory where MSEdge.exe is located. I noticed that it only works if you point to the dir and not the .exe.
So it would be something like: C:\Program Files (x86)\Microsoft\Edge Dev\Application\
I did face the same issue, and trust me I tried doing every possible thing, but you know what helped me, though it might sound lame to you, the Edge browser version it was old, when I updated it, it worked for me, the error was resolved, do give it a shot as well
Unlike Chrome browser it does not throws error lie the browser driver version and browser are incompatible.
Yours's sincerely,
A frustrated Automation tester

Appium/Protractor - Cordova app - When I try to run simple test I get following error - Failed to get sockets matching: #webview_devtools_remote_

I'm trying to run a simple test on my hybrid app with Appium + Protractor and I am unable to since I am getting following error:
Failed to get sockets matching: #webview_devtools_remote_.*15239
I am using Ubuntu, and on it I have set up Appium and Protractor, tried literally every solution I have found on the internet, could not resolve the issue.
Only thing that would "remove" the error is adding following code into capabilities:
chromeOptions: {
androidPackage: "com.android.chrome"
},
But then I only get in the app, and Appium server just gets stuck at:
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://127.0.0.1:8001/wd/hub/session] with body: {"desiredCapabilities":{"chromeOption {"androidPackage":"com.android.chrome","androidUseRunningApp":true,"androidDeviceSerial":"1cdc4ed10c027ece"}}}
It won't start the spec file at all.
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
allScriptsTimeout: 50976,
specs: [
'test.js'
],
capabilities: {
platformName: 'Android',
platformVersion: '8.0.0',
deviceName: 'Galaxy S9',
app: 'path_to_app',
autoWebview: true,
browserName: '',
appPackage: 'app_package_name',
newCommandTimeout: '140',
chromeOptions: {
androidPackage: "com.android.chrome"
}
},
onPrepare: function () {
jasmine.getEnv().addReporter(new SpecReporter({displayStacktrace: 'all'}));
},
framework: 'jasmine',
jasmineNodeOpts: {
print: function () {}, //remove protractor dot reporter
defaultTimeoutInterval: 100000
}
}
It seems to be a common appium problem.
Issue from github: https://github.com/appium/python-client/issues/255
Fix:
See here: https://github.com/blutter/appium-crosswalk-fix
This also happens if you want to switch to a web browser on the mobile phone, while you have already instanciated an appium on a mobile app.
To avoid having this exception, such as described in
https://github.com/appium/appium/issues/11189, [Chromedriver] Error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. (Original error: unknown error: Failed to get sockets matching: #webview_devtools_remote_.*24811 ,
before trying to switch to your web browser on the mobile phone just, reinstantiate the appium forcefully to web like below. Appium will pilot the appp then be forced and
switch cleanly to the web browser without complaining anymore :
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome"); // or other browsers
desiredCapabilities.setCapability("noReset", true );
try
{
URL url = new URL("http://127.0.0.1:4723/wd/hub");
AppiumDriver driver = new AppiumDriver(url, desiredCapabilities);
}
catch (Exception e )
{
}
I got rid of a similar error after changing the default browser of the mobie device to Chrome from Samsung. Also updated the chromedriver version on laptop running appium server to match the version of Chrome version running on mobile. And appium was started with appium --chromedriver-executable=/usr/local/bin/chromedriver.
Also had setWebContentsDebuggingEnabled=true in desired_capabilities.

Q: CodeceptJS "unknown error": call function result missing 'value'

This is my Test
Feature('Test');
Scenario('test something', (I) => {
I.amOnPage("");
I.see("Welcome");
I.fillField('j_username', 'xxxxxx');
I.wait(3);
});
This is my codeceptjs.JSON
{
"tests": "asd/*_test.js",
"timeout": 10000,
"output": "./output",
"smartwait":"1000",
"helpers": {
"WebDriverIO": {
"url": "http://localhost:8080/xxxx/",
"browser": "chrome"
}
},
"include": {
"I": "./steps_file.js"
},
"bootstrap": false,
"name": "yenideneme"
}
I am try CodeceptJS with Webdriverio helper for end-to-end tests. Connect to the server and I.see("") passed. But added I.fillField() taken this Error=
test something:
unknown error: call function result missing 'value'
I try to update chrome and chromedriver but not worked.
And other project taken Error=
2) e2e
"after each" hook: finalize codeceptjs for "welcome Page #fristBlank":
unknown error: call function result missing 'value'
It may be related to an issue with Chrome 65. After upgrading from Chrome 64, I started seeing the same issue. Downgrading to the version 64 should help temporarily.
A long-term solution is making sure that Chromedriver is upgraded to version 2.36, which is supposed to work with Chrome 65. However, a simple "npm install chromedriver" may not be sufficient. Your Selenium may still try to load the old version. The actual solution depends on your environment setup.
Got the same problem yesterday after a chrome update(v65).
Uninstalled and downloaded version 63 from this site.
http://www.geocities.jp/ecvcn/exam/chrome_installer.html
Problem Solved.

phantom JS configuration when used with InternJS

I want to use phantomJS with Intern for functional testing.
I Installed phantomJS and ran the command "phantomjs --webdriver 4444", it ran successfully.
Then tried to run intern-runner with the command "intern-runner config=tests/intern" -file tests/intern is shown at the end of the post-.
but i keep getting the error
intern-runner config=tests/intern
Listening on 0.0.0.0:9000
Tunnel started
Suite phantomjs on any platform FAILED
UnknownError: [POST http: //localhost:4444/wd/hub/session / {"desiredCapabilities":{"browserName":"phantomjs","name":"tests/intern","idle-timeout":60}}] An unknown server-side error occurred while processing the command.
on intern.
and the error
[ERROR - 2015-10-14T10:14:35.611Z] RouterReqHand - _handle.error - {"message":"{
\"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accept\":\"a
pplication/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-type\":\"
application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/4.1.2\"
},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlParsed\"
:{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\",\"path
\":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"password
\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"s
ource\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}","name":"Missing
Command Parameter","line":85,"sourceId":65775352,"sourceURL":":/ghostdriver/req
uest_handlers/session_manager_request_handler.js","stack":"Missing Command Param
eter: {\"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accep
t\":\"application/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-ty
pe\":\"application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/
4.1.2\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlP
arsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\"
,\"path\":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"p
assword\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\
"\",\"source\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}\n at :
/ghostdriver/request_handlers/session_manager_request_handler.js:85\n at :/gh
ostdriver/request_handlers/session_manager_request_handler.js:44\n at :/ghost
driver/request_handlers/router_request_handler.js:70","stackArray":[{"sourceURL"
:":/ghostdriver/request_handlers/session_manager_request_handler.js","line":85},
{"sourceURL":":/ghostdriver/request_handlers/session_manager_request_handler.js"
,"line":44},{"sourceURL":":/ghostdriver/request_handlers/router_request_handler.
js","line":70}]}
on phantomjs - this error appears after running the intern-runner-.
does anyone know what the problem is?.
p.s. I'm using phantomJS v.1.9.8
tests/intern :
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
environments: [
{ browserName: 'phantomjs' }
],
maxConcurrency: 3,
useSauceConnect: false,
loaders: {
'host-browser': 'node_modules/requirejs/require.js'
},
tunnel: 'NullTunnel',
functionalSuites: [ 'tests/functional/modetest' ],
});
PhantomJS 1 is ancient (it uses a version of WebKit from 2012) and not supported. You must use PhantomJS 2+ with Intern.