Nightwatch crashes as soon as browser appears - was working and made no changes - nightwatch.js

I've had a Nightwatch project running on a daily timer testing my site. I have a log file that I check every few weeks to make sure everything is going smoothly. Today I noticed it's been running, but crashing after a couple seconds of running (it usually takes half an hour to do everything).
I haven't changed the code, updated any of the packages or node, or purposefully changed anything else on my computer in the past week.
I placed a lot of logging calls in my code (I had to use my fs logger because console.log is not showing up after the process runs like it normally does). It doesn't always quit at the same point through the code, so I figured it was a Nightwatch problem and not mine.
I created a simple test file I could use to see if my complicated tests were messing things up. It prints the logs to my file, but doesn't run any of the tests and the browser pops up for less than a second before the whole thing crashes.
Current test:
const fs = require('fs');
module.exports = {
'#tags': ['getDistricts'],
'Get Districts Assert Title': function (browser) {
fs.appendFile("./log.txt", "\nBROWSER: " + JSON.stringify(browser), function (err) { });
browser.pause(100000); //prevent method from ending before tickets are retrieved
fs.appendFile("./log.txt", "\nNew run: " + new Date(), function (err) { });
browser
.url('https://www.google.com')
.waitForElementVisible('body')
.assert.title('Google')
fs.appendFile("./log.txt", "\nRan tests", function (err) { });
}
};
Log file:
BROWSER: {"capabilities":{},"globals":{"waitForConditionTimeout":15000},"sessionId":null,"options":{"screenshots":true,"screenshotsPath":"./node_modules/nightwatch/screenshots/","skip_testcases_on_fail":true,"log_screenshot_data":true,"username":"${SAUCE_USERNAME}","accessKey":"${SAUCE_ACCESS_KEY}","desiredCapabilities":{"browserName":"chrome","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","chromeOptions":{"args":["Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46\n (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3","--window-size=640,1136"]},"name":"Temp Test"}},"launchUrl":"http://localhost","launch_url":"http://localhost","screenshotsPath":"./node_modules/nightwatch/screenshots/","Keys":{"NULL":"","CANCEL":"","HELP":"","BACK_SPACE":"","TAB":"","CLEAR":"","RETURN":"","ENTER":"","SHIFT":"","CONTROL":"","ALT":"","PAUSE":"","ESCAPE":"","SPACE":"","PAGEUP":"","PAGEDOWN":"","END":"","HOME":"","LEFT_ARROW":"","UP_ARROW":"","RIGHT_ARROW":"","DOWN_ARROW":"","ARROW_LEFT":"","ARROW_UP":"","ARROW_RIGHT":"","ARROW_DOWN":"","INSERT":"","DELETE":"","SEMICOLON":"","EQUALS":"","NUMPAD0":"","NUMPAD1":"","NUMPAD2":"","NUMPAD3":"","NUMPAD4":"","NUMPAD5":"","NUMPAD6":"","NUMPAD7":"","NUMPAD8":"","NUMPAD9":"","MULTIPLY":"","ADD":"","SEPARATOR":"","SUBTRACT":"","DECIMAL":"","DIVIDE":"","F1":"","F2":"","F3":"","F4":"","F5":"","F6":"","F7":"","F8":"","F9":"","F10":"","F11":"","F12":"","COMMAND":"","META":""},"expect":{},"assert":{},"verify":{},"currentEnv":"tempTest_1","currentTest":{"name":"Get Districts Assert Title","module":"tempTest","results":{"steps":[],"passed":0,"failed":0,"errors":0,"skipped":0,"tests":0,"testcases":{},"timestamp":"Thu, 22 Aug 2019 18:50:31 GMT","time":0},"group":""}}
New run: Thu Aug 22 2019 13:50:31 GMT-0500 (Central Daylight Time)
Ran tests
npm test --verbose:
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'test',
npm verb cli '--verbose' ]
npm info using npm#6.9.0
npm info using node#v10.16.0
npm verb run-script [ 'pretest', 'test', 'posttest' ]
npm info lifecycle artms-nightwatch#1.0.24~pretest: artms-nightwatch#1.0.24
npm info lifecycle artms-nightwatch#1.0.24~test: artms-nightwatch#1.0.24
> artms-nightwatch#1.0.24 test C:\Users\malai\Nightwatch
> nightwatch --env local
Starting selenium server in parallel mode... started - PID: 23680
Started child process for: tempTest
>> tempTest finished.
npm verb lifecycle artms-nightwatch#1.0.24~test: unsafe-perm in lifecycle true
npm verb lifecycle artms-nightwatch#1.0.24~test: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\malai\Nightwatch\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\Java\jdk1.8.0_211\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Users\malai\AppData\Local\Microsoft\WindowsApps;C:\Users\malai\AppData\Roaming\npm;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Users\malai\.dotnet\tools
npm verb lifecycle artms-nightwatch#1.0.24~test: CWD: C:\Users\malai\Nightwatch
npm info lifecycle artms-nightwatch#1.0.24~test: Failed to exec test script
npm ERR! Test failed. See above for more details.
npm verb exit [ 1, true ]
npm timing npm Completed in 4145ms
npm verb code 1

I was never able to figure out why it stopped working, but I started from scratch and rebuilt the project on the most recent version of Nightwatch and copied my tests over and it's working again.

Related

Gulp error missing script: build in MVC project

I have given a project which works ok on other PCs but on mine it doesnt work.
When I hit build, it reports in node logs error missing script: build
Steps that I've done
installed nodejs
installed gulp globally and locally (inside of mvc project)
*Warning: I have different versions of nodejs and gulp then it specified in solution.
here is the package.json:
{
"name": "test",
"version": "1.0.0",
"private": true,
"scripts": {
"css": "gulp"
},
"engines": {
"node": "5.9.1",
"npm": "3.7.3"
},
"devDependencies": {
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-less": "^3.1.0",
"gulp-minify-css": "^1.2.4",
"gulp-sourcemaps": "^2.3.0",
"gulp-uglify": "^2.0.0",
"gulp-util": "^3.0.7",
"merge-stream": "^1.0.0"
}
}
so when I hit command npm run gulp it says that gulp script doesnt found - expected.
but when I hit npm run css Im gettin an error:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'css'
1 verbose cli ]
2 info using npm#6.13.1
3 info using node#v13.3.0
4 verbose run-script [ 'precss', 'css', 'postcss' ]
5 info lifecycle tiptimes#1.0.0~precss: tiptimes#1.0.0
6 info lifecycle tiptimes#1.0.0~css: tiptimes#1.0.0
7 verbose lifecycle tiptimes#1.0.0~css: unsafe-perm in lifecycle true
8 verbose lifecycle tiptimes#1.0.0~css: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Work\tiptimes\MvcApplication\node_modules\.bin;C:\Program Files\ConEmu\ConEmu\Scripts;C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\Program Files\Microsoft MPI\Bin\;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\ProgramData\chocolatey\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Git\cmd;C:\Program Files\Seq\;C:\Program Files\Seq\Client\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\dotnet\;C:\Users\Stefan Cvetkovic\AppData\Local\Microsoft\WindowsApps;C:\Users\Stefan Cvetkovic\.dotnet\tools;C:\Program Files (x86)\Rico Suter\NSwagStudio\;C:\Users\Stefan Cvetkovic\AppData\Roaming\npm;C:\Users\Stefan Cvetkovic\.dotnet\tools
9 verbose lifecycle tiptimes#1.0.0~css: CWD: C:\Work\tiptimes\MvcApplication
10 silly lifecycle tiptimes#1.0.0~css: Args: [ '/d /s /c', 'gulp' ]
11 silly lifecycle tiptimes#1.0.0~css: Returned: code: 1 signal: null
12 info lifecycle tiptimes#1.0.0~css: Failed to exec css script
13 verbose stack Error: tiptimes#1.0.0 css: `gulp`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:219:5)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:219:5)
13 verbose stack at maybeClose (internal/child_process.js:1027:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:285:5)
14 verbose pkgid tiptimes#1.0.0
15 verbose cwd C:\Work\tiptimes\MvcApplication
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "css"
18 verbose node v13.3.0
19 verbose npm v6.13.1
20 error code ELIFECYCLE
21 error errno 1
22 error tiptimes#1.0.0 css: `gulp`
22 error Exit status 1
23 error Failed at the tiptimes#1.0.0 css script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Here are my files in the root of MVCApp
https://i.imgur.com/QOo2OLE.png
Im using vs2017
Any help would be appreciated!
Since it works on other PC, double check their nodejs version and make sur it matches yours.
Also, you either want to run gulp directly (gulp yourGulpTask) or add node script within package.json and run them with npm. Ex (add scripts node in your package.json file):
"scripts": {
"build": "gulp build",
"test": "gulp test",
"watch": "gulp watch",
},
With the previous scripts declaration, if the the gulp task build, test and watch are define within the gulp.js file, you could run the following :
npm run build
npm run test
npm run watch
When gulp is ran without arguments, it is trying to run the default task. In your case, the css script is calling gulp without argument, therefore calling the default gulp task([ 'precss', 'css', 'postcss' ]).
To debug, make sure you can run these gulp-tasks independently
gulp precss
gulp css
gulp postcss
It feels like your precss works fine. Your css task is bugging and we never get to postcss.
The meaningfull error on your log is this one :
verbose lifecycle tiptimes#1.0.0~css: unsafe-perm in lifecycle true
Most likey confirming the nodejs version issue :: npm run test - unsafe-perm in lifecycle
On a quick note, running npm run gulp would be weird. Should always give meaningfull name to your scripts... Gulp.js conventions for tasks names

Error: EPERM: operation not permitted, open

{ Error: EPERM: operation not permitted, open 'C:\Users\Vivek Sharma\apps\testAp
p\www\assets\imgs\Thumbs.db’
**errno: -4048,
code: ‘EPERM’,
syscall: ‘open’,**
path: ‘C:\Users\Vivek Sharma\apps\testApp\www\assets\imgs\Thumbs.db’ }
[03:09:32] deeplinks started …
[03:09:32] deeplinks finished in 110 ms
[03:09:32] ngc started …
[03:09:59] ngc finished in 26.71 s
[03:09:59] preprocess started …
[03:09:59] preprocess finished in 3 ms
[03:09:59] webpack started …
[03:11:33] webpack finished in 94.64 s
[03:11:33] uglify started …
[03:11:33] sass started …
Error: EPERM: operation not permitted, open ‘C:\Users\Vivek Sharma\apps\testApp
www\assets\imgs\Thumbs.db’
(node:14288) PromiseRejectionHandledWarning: Promise rejection was handled async
hronously (rejection id: 1)
[03:11:36] sass finished in 2.99 s
[03:11:36] cleancss started …
[03:11:40] cleancss finished in 3.62 s
[03:12:08] uglify finished in 34.76 s
---------------------END-----------------------------------
This error occurs when trying to build apk. using ionic cordova build android --release --prod in windows cmd
ionic v-3.19.0
cordova -v-8.0.0
node -v-8.8.3
npm -v-5.3.0
WINDOWS 8.1 64 bit.
full control is given to the system.
enter image description here
please help
Thank you, Developers, for responding to my query. I have resolved the issue. The problem was, Windows keeps building Thumbnails and stores them as Thumbs.db on the system.This prevents the system from copying, moving, deleting or renaming a folder. I prevented further caching of thumbnails and deleted the Thumbs.db from the project folder.
This is the procedure if anyone else comes across this problem:
1. Disabling Thumbs.db:
https://www.nextofwindows.com/what-is-thumbs-db-files-and-how-to-disable-and-remove-them
2. Next, to remove Thumbs.db:
https://www.youtube.com/watch?v=N7MgnYCMvHE
This will do the job. :)
Seems like your folder name has a white space try to rename the folder name and try to run it again.
Existing Path:
C:\Users\Vivek Sharma\apps\testAp p\www\assets\imgs\Thumbs.db
Change Path like this:
C:\Users\VivekSharma\apps\testApp\www\assets\imgs\Thumbs.db
You could see whitespace in between Vivek Sharma change it to VivekSharma For more info check this out:
Error: EPERM: operation not permitted

Error EOF when trying to resize images using Gulp on Windows

I get an error as follows when calling resize:images task in my gulpfile (see bottom) ...
events.js:160
throw er; // Unhandled 'error' event
^
Error: Error: write EOF
at finish (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gulp-gm\index.js:40:21)
at gm.<anonymous> (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\async\lib\async.js:485:30)
at emitMany (events.js:127:13)
at gm.emit (events.js:201:7)
at gm.<anonymous> (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gm\lib\getters.js:70:16)
at Socket.cb (C:\Users\brendan\Documents\Code\Web\TheOrm\WWW\v3\node_modules\gm\lib\command.js:322:16)
at Socket.g (events.js:291:16)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at onwriteError (_stream_writable.js:340:10)
Imagemagick is installed and seems to work from the command line. i.e. magick -help gives sensible output and you can save the inbuilt test logo image.
I have tried various other gulp libraries including gulp-responsive-images which gives an empty pipe error.
I tried this under the Linux Subsystem for Windows and it works fine - it seems that this is a Windows only problem.
After forking gulp-image-resize and running the test suite I get the following error ...
...
[14:18:20] Starting 'image_resize:interlace_and_resize_imagemagick'...
events.js:160
throw er; // Unhandled 'error' event
^
Error: write EPIPE
at exports._errnoException (util.js:1026:11)
at Socket._writeGeneric (net.js:710:26)
at Socket._write (net.js:729:8)
at doWrite (_stream_writable.js:328:12)
at writeOrBuffer (_stream_writable.js:314:5)
at Socket.Writable.write (_stream_writable.js:241:11)
at Socket.write (net.js:656:40)
at gm._spawn (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\command.js:194:18)
at gm._exec (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\command.js:167:17)
at gm.proto.(anonymous function) [as size] (C:\Users\brendan\Documents\Code\OpenSource\gulp-image-resize\node_modules\gm\lib\getters.js:68:12)
Unfortunately, the repo had bug reporting disabled - does anyone know how this might be remedied?
Here is my gulpfile.js ...
let gulp = require('gulp');
let imageResize = require('gulp-image-resize');
let path = require('path');
let rename = require('gulp-rename');
let debug = require('gulp-debug');
let INPUT_DIR = './NO_UPLOAD/img_src';
let OUTPUT_DIR = './NO_UPLOAD/img_tmp';
gulp.task('resize:images', function() {
relFns = [
'logo.png',
'image.png',
].map((f) => path.join(INPUT_DIR, f));
return gulp.src(relFns, { base: INPUT_DIR })
.pipe(debug({ title: 'resized' }))
.pipe(imageResize({
width: 100
}))
.pipe(rename((path) => { path.basename += '.sml' }))
.pipe(gulp.dest(OUTPUT_DIR));
});
There were a number of issues ...
Make sure Graphicsmagick is installed as well (may not be necessary but did not do any harm to install)
make sure both gm and magick are in your path
After referring to a comment on this post, I found restarting the computer fixed the issue. (I was surprised at the restart since opening up a new console usually works.)
Finally make sure that you don't run from a console opened from Visual Studio Code instance. VSCode is a 32bit app and launches a 32bit console which does not run 64bit versions of Imagemagick. Instead launch the console from Explorer.

How to install DNX Secret Manager in Mac OSX

I'm developing with ASP.NET5 on Mac OS X. I want to implement OAuth and use Secret Manager to store my secret configuration, so I'm following this DNXSecret Configuration page.
https://github.com/aspnet/Home/wiki/DNX-Secret-Configuration
But, after following the instructions, I couldn't successfully install user-secret command to my Mac, and I'm pretty much stuck.
As the first step, I installed DNVM and confirmed dnvm list command returns Mono as the runtime engine.
$ dnvm list
Active Version Runtime Arch Location Alias
------ ------- ------- ---- -------- -----
* 1.0.0-beta4 mono ~/.dnx/runtimes default
I also installed Yeoman, Grunt, Bower etc, and dnu restore command worked fine. I successfully showed a Yeoman scaffolded ASP.NET5 page both locally and on Azure.
Then I started to install Secret Manager, following the above page. In the beginning, the following command failed:
dnu commands install SecretManager
with the error below:
Errors in /Users/<username>/.dnx/bin/packages/SecretManager/1.0.0-beta4/app/project.json
Unable to locate SecretManager >= 1.0.0-beta4-10173
So, I modified the above 'project.json' file in its "dependencies" block as:
{
"version": "1.0.0-*",
"description": "ASP.NET 5 tool to manage user secrets.",
"dependencies": {
"SecretManager": "1.0.0-beta4" // <<- modified here
//"SecretManager": "1.0.0-beta4-10173"
},
"commands": {
"user-secret": "SecretManager"
},
"userSecretsId": "testuserSecretsId",
"frameworks": {
"dnx451": {},
"dnxcore50": {
"dependencies": {
"System.Console": "4.0.0-beta-*"
}
}
},
"entryPoint": "SecretManager",
"loadable": false
}
(before) "SecretManager": "1.0.0-beta4-10173"
(after) "SecretManager": "1.0.0-beta4"
Then the command finished successfully and SecretManager seems to be installed with the result below:
konishis-air:AspNetSocialLoginTest Ryuji$ dnu commands install SecretManager
GET https://www.nuget.org/api/v2/FindPackagesById()?Id='SecretManager'.
OK https://www.nuget.org/api/v2/FindPackagesById()?Id='SecretManager' 1674ms
Restoring packages for /Users/Ryuji/.dnx/bin/packages/e27d166dcf594105be47fff78420df10/project.json
Writing lock file /Users/Ryuji/.dnx/bin/packages/e27d166dcf594105be47fff78420df10/project.lock.json
Restore complete, 246ms elapsed
Restoring packages for /Users/Ryuji/.dnx/bin/packages/SecretManager/1.0.0-beta4/app/project.json
GET https://www.nuget.org/api/v2/FindPackagesById()?Id='System.Console'.
OK https://www.nuget.org/api/v2/FindPackagesById()?Id='System.Console' 1395ms
Writing lock file /Users/Ryuji/.dnx/bin/packages/SecretManager/1.0.0-beta4/app/project.lock.json
Restore complete, 1751ms elapsed
The following commands were installed: .project.json, user-secret
However, when I run user-secret command, I get 'command not found'.
Sorry, that is a known issue and we've fixed in beta5.
You have two options:
Pass the fallback source: dnu commands install secretmanager 1.0.0-beta4 -f https://www.myget.org/F/aspnetrelease/api/v2
Update to the latest beta5 bits

Error: Individual stylesheets must be in the sass directory

My CSS doesn't work. Here is my terminal log:
$ gulp sass
Using gulpfile ~/dev/myproject/gulpfile.js
Starting 'sass-ionic'...
Starting 'sass-myproject'...
Individual stylesheets must be in the sass directory.
{ [Error: Compass failed]
message: 'Compass failed',
fileName: '/Users/me/dev/myproject/scss/main.scss',
showStack: false,
showProperties: true,
plugin: 'gulp-compass',
__safety: { toString: [Function] } }
Finished 'sass-ionic' after 634 ms
I am using Ionic Framework.
The funny part is that I have two computers with pretty much same setup and the other works fine and the other gives the error above. I'm using git so the both projects have identical files and folder structure.
EDIT: After downgrading compass:
Here is what I get after 'gulp sass':
Starting 'sass-ionic'...
Starting 'sass-murikka'...
Finished 'sass-ionic' after 614 ms
warning Webkit only supports pixels for the start and end stops for radial gradients. Got: 100%
warning Webkit only supports pixels for the start and end stops for radial gradients. Got: 100%
identical ./www/css/main.css
Finished 'sass-murikka' after 843 ms
Starting 'sass'...
Finished 'sass' after 13 μs
On the other computer I get exactly the same output except
identical ./www/css/main.css
-->
overwrite ./www/css/main.css
For anybody stumbling across this bug on a Windows environment, first check your config paths to ensure they're not absolute or some other nonsense.
Next, make sure you use the correct case with your directories when navigating to your project directory. Since Windows is case-insensitive, it will allow you to cd myproject/source/ when it's actually MyProject/source/. gulp-compass will give this error if you run your gulp task using just cd myproject/source/ lower case.
Check your terminal CWD and make sure it matches the case: $ MyProject/source/ > gulp sass or some such.
Check if Ruby is installed in your computer. I had the same error and installing ruby solved the problem

Resources