Appium node sample tests not running - javascript

I am https://github.com/appium/sample-code
and when I run file at sample-code/sample-code/examples/node/android-simple.js
with command mocha android-simple.js attached is the output with error.
What am I doing wrong here.

This Error will come only when your environment is not set properly..
Make Sure that your Target device(Android Emulator) is up and running and device name that you mentioned in desired capabilities are right

Related

(PERCY) Warning: skipping visual tests. PERCY_TOKEN was not provided

I'm getting this error below everytime I try to run 'npx percy exec -- node snapshots.js'.
PowerShell Terminal
Problem Image ->
https://i.stack.imgur.com/XCSj6.png
I have followed this Tutorial -> https://docs.percy.io/docs/percyscript-tutorial
Anyone know how to solve this? I looked everywhere and found nothing.
Thank you in advance!
PowerShell has a different syntax for working with Environment Variables.
Try this:
$env:PERCY_TOKEN = "token"
Powershell Help - About Environment Variables
To set up PERCY_TOKEN on windows we have to use powershell.
1.Open powershell on windows
2. Go to project library through commands cd, cd..
3.Set the PERCY_TOKEN $env:PERCY_TOKEN='your token'
4. Then run your project using powershell through your command npm run test:percy

Cannot Run Nightwatch Tests in Safari

I have followed all instructions in the Nightwatch docs and followed many issues in github. I believe I have the correct setup in my nightwatch.json for safari. Safari does launch when I run a test against it but then all the commands in my test fail. For example I have a global beforeEach to resize the browser window which works great in Firefox and Chrome but fails in Safari with
The command 'POST /session/FA198F5F-EE09-4129-9FF0-F55FEA0EE6F0/window/current/size' was not found.
If I remove that then the first step in my test (which is a waitForElementVisible test fails with the error of
The command 'GET /session/FA198F5F-EE09-4129-9FF0-F55FEA0EE6F0/element/node-F5A12DD5-2557-4AE6-806A-0A0B99B63EFC/displayed' was not found.
Again, I'm certain my config is setup properly as nightwatch is launching the safari browser but then failing on the test commands. I have enabled safaridriver and checked 'Allow Remote Automation' but everything still fails. Has anyone run into this issue?
If you used Appium and the XCUITest driver as your WebDriverAgent then you can use browser.execute('mobile:gesture',{arguments}) to replace all the 'Element Interaction' commands. The full list of gestures can be found here
For the command like waitForElementVisible(), you can use the assertions commands instead (in my case I have used assert.visible('element css selector')).
Hope they will change things in NightWatch v2 but for now we can only work around that

How can i debug a nodejs backend with node-inspector?

I am trying to debug my backend and i am not really sure if i am doing it the correct way.
I have set up the debugging as follows:
Node 6.9.1 and node-inspector 0.12.8
open a command prompt and run the following command:
node-inspector --web-port=3030 (server app port)
open another command prompt and run the following command:
node --inspect --debug-brk server.js
browse to the given URL in the second command prompt log on screen
press F8 to make the server run
eventually put some others breakpoints
browse on another tab to your app (address and port defined in 1-)
see server execution stops on breakpoints defined on step 5.
Now when i run node --inspect app.js and everything looks good so far. I can debug the first start in the app.js. But if I want to debug an endpoint with POSTMAN, I get the error "Cannot POST /api/trainingsWeek". The endpoint works if I don't debug.
Do I have to take another address? Or another tool than POSTMAN?
ANd what is the difference between node --inspect app.js and node-debug
GitHub Issue
UPDATE
This was my stupid mistake :P Here is the solution: https://github.com/node-inspector/node-inspector/issues/907#issuecomment-280620108
I use VS Code to debug. I guess you don't need node-inspector, it will run with the integrated debugger from Node. To get it running, open your project and the debug view. There should be no configuration available. Click on the little wheel -> choose node.js as the environment.
After that the standard json will be created and looks like this:
And then click on the play button with the selection start programm. With that the debugging should run. Now you can use POSTMAN with the same url when you just run your server and the debugger from VS Code should hit your breakpoint.

PhantomJS not working with Jenkins

I followed Web page Capture and save to image using phantomjs lib and able to save screenshot on my local.
However when executing PhantomJS command with Jenkins, following error is generated: "_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL." and screen shot is not saved on Jenkins.
Can anyone please guide me?
I've found two possible solutions to this problem:
As user2325313 commented, if you login as the Jenkins' user you should be able to avoid this issue.
Run Jenkins as a standalone application instead of a daemon. To do so, locate your Jenkins .war file and execute it from the terminal using the following command :
java -jar /Applications/Jenkins/jenkins.war

Failing to debug with node-inspector - what is wrong?

I have a javascript code that checks whether a point is inside a polygon. I am trying to debug it with node-inspector, following these steps:
In the first window:
PS Z:\dev> node-inspector.cmd
info - socket.io started
visit http://0.0.0.0:8080/debug?port=5858 to start debugging
In the second window:
PS Z:\dev\poc\SDR> node --debug-brk .\IsPointInside.js
debugger listening on port 5858
Now I navigate to http://localhost:8080/debug?port=5858 in my Chrome browser.
What happens is that Chrome gets stuck waiting for localhost presenting me the empty screen.
I must add that I have successfully debugged the r.js javascript optimizer using the same steps before, but now I cannot debug it as well.
according to this there seems to be an order in which the components should be started.
Its application -> debugger -> web browser.
Could be your issue.
You can also send a "debug on demand" command. Use this command:
kill -USR1 $PROCESSID

Categories