Nightwatch starts selenium and then hangs indefinitely - nightwatch.js

I'm running a simple nightwatch test on a Windows 10.1 machine. The tests starts up selenium server (e.g., selenium server... started - PID: 12784), but it never gets to the test code. I can use a browser to get to the localhost server page that is spawned from the "node nightwatch.js -t test.js" command, so I know the server is working properly. I've also tried running nightwatch with different browsers, e.g., -e chrome, firefox, IE, and phantomjs, and none of them work. Putting --verbose on the command doesn't provide any more console spew, so not sure how to debug this. I'm running with selenium-server-standalone v2.53.0.
Any suggestions?

Solved my own problem. Turns out the problem was with incompatible versions of node, nightwatch, and python. I figured it out by creating a totally separate clone of my repository and reinstalling all the node/nightwatch/selenium dependencies. Would be nice if there was a debug feature that could be enabled to indicate more details about where a node or nightwatch application is during application startup. I learned of node-inspector, so I'll check it out as a possible debug tool.

Related

running selenium test suites created by selenium ide (firefox) over command line (ubuntu)

I have the problem that my selenium tests created via the firefox plugin "Selenium IDE" won't work when executed over cli with htmlsuite command. The test should simply open google.de in firefox browser.
I can record and execute the test just fine in selenium ide, but when i execute the following command in cli:
java -jar /var/lib/jenkins/jobs/SuiteCRM_CI_Test/selenium-server-standalone-2.48.2.jar -debug -log /home/jenkins/wtflog.log -firoxProfileTemplate /var/lib/jenkins/jobs/SuiteCRM_CI_Test/firefox_profile -htmlSuite *firefox http://google.de /home/koschig/Arbeitsfläche/seleniumtests/googlesuite.html results.html
All that happens is, firefox will be opened with 2 tabs: one being the firstrun" tab and the other is the following:
chrome://src/content/TestRunner.html?auto=true&multiWindow=true&defaultLogLevel=info&baseUrl=http%3A%2F%2Fgoogle.de&resultsUrl=http://localhost:4444/selenium-server/postResults&test=http%3A%2F%2Flocalhost%3A4444%2Fselenium-server%2Ftests%2Fgooglesuite.html
which gets me an error, file not found
Well, I don't know where the first half of this url comes from, the second half is crafted with the parameters I wrote in the command line.
Does anyone know how to solve this problem? I expected that firefox will be opened and google.de will be accessed...

selenium UI automation through Teamcity build agent

We are running selenium UI automation through Teamcity build Agent but it couldnt launch firefox and the error is below:
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host localhost.localdomain on port 7055 after 45000 ms. Firefox console output:
Error: cannot open display: :0.0
Error: cannot open display: :0.0
Before trying with Teamcity build agent , we have executed the selenium cases manually (by running the ant script) in the build agent VM and it could launch firefox and executed the cases successfully.
so, we don't see any problem of compatibilty between firefox and selenium jar version.
It seems like your configuration misses a virtual display.
You need a virtual display if you want to run selenium with a browser such as Firefox, IE, ..., without any display. You could use Xvfb for that, or headless browser such as phantomJS.
There are a lot of articles about that, like this one
Or you could export your display to a monitoring environment, if you want selenium tests to be displayed while they run.

Headless testing display error

Background
I am running a set of selenium tests using a Maven and Jenkins with Testng. I had them working fine headlessly up until a week ago. Jenkins sits on the server accessible with port 8080. The tests also run fine through eclipse.
Software Versions
I have read lots about Firefox being incomparable with selenium so here is a list of software and versions that I am using.
Firefox: 39
Maven: 3.3.3
Java: 1.7.0_79
Selenium: 2.46 & 2.47(currently 2.47)
Jenkins: 1.622
Xvnc: 1.3.9
ubuntu 14
Error
After I run the tests and the fail I check the console through Jenkins. The error I am getting makes me think it's a problem with Xvnc and firefox but I can't pin point it. I get a NotConnectedException. The firefox console error has changed a few times here is a list of different errors the console has shown me.
Error: cannot open display: :87
firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :46.
firefox: Fatal IO error 2 (No such file or directory) on X server :78.
Research
I've been on bugzilla but cant find a conclusive answer to the problem.
I've also looked around SO but found no fixes.
Conclution
From what I have gathered it is something to do with Xvnc, Could running
sudo apt-get update
make changes to how Xvnc operates? I have updated the packages some time last week but our testers didn't check Jenkins properly when adding new tests and as such I've wasted and entire day trying to pin point when and what the problem is.
Question
What would cause Jenkins to return errors like this, how can I fix them and how can I prevent something doing this again?
EDIT 1
The display variable seems to be the issue, upon typing the command
echo $DISPLAY
There is no response just an empty line.
EDIT 2
running the command
export DISPLAY=:0.10
no gives the result
:0.10
when I echo $DISPLAY
I think the DISPLAY varibale is not functioning as expected and hence firefox is unable to connect to it. To know more about the $DISPLAY refer this link https://askubuntu.com/questions/432255/what-is-display-environment-variable
Try to run this command on the slave node where the job runs, this should give you the required setting for the tests to connect and run.
nohup /usr/bin/Xvfb :2 –screen 0 1024x768x24 > /dev/null 2>&1 &

Selenium Web Driver does not work on xvfb

I want to run my Robot Framework tests which include Selenium2Library keywords on an Ubuntu remote machine so they should be run without a display. At first I just tried to run a simple test and get following result:
WebDriverException: Message: The browser appears to have exited before we could connect. If you specified a log_file in the FirefoxBinary constructor, check it for details.
I installed xvfb in order the run headless tests and run these lines on remote shell:
sudo Xvfb :10 -ac
export DISPLAY=:10
Now i am getting the following error and I can't get rid of it
test | FAIL |
WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
I checked nearly all questions here about Selenium on xvfb and this specific error.
Since some mentioned about Selenium - Firefox incompability, I tried updating selenium (it is up to date, version 2.46.0), my Firefox was latest and i has not worked.
Then I tried using an old firefox relase (35.0) which is also not worked
Now I'm trying a solution for this problem and I am almost sure it is about fireofx.
Thanks for your answers and advices
EDIT:
->Runing tests with chrome works just fine
->Also i checked my iptables if there is a rule blocking network to local, it is in default state

Meteor: Debug on server side

Does anyone know a good method to debug server side code?
I tried enable Node.js debug then use node-inspector but it does not show any of my code.
I end up using console.log but this is very inefficient.
Update: I found the following procedure works on my Linux machine:
When you run Meteor, it will spawn two processes
process1: /usr/lib/meteor/bin/node /usr/lib/meteor/app/meteor/meteor.js
process2: /usr/lib/meteor/bin/node /home/paul/codes/bbtest_code/bbtest02/.meteor/local/build/main.js --keepalive
You need to send kill -s USR1 on process2
Run node-inspector and you can see your server code
On my first try, I modify the last line on meteor startup script in /usr/lib/meteor/bin/meteor to
exec "$DEV_BUNDLE/bin/node" $NODE_DEBUG "$METEOR" "$#"
and run NODE_DEBUG=--debug meteor on command prompt. This only put --debug flag on process1 so I only see meteor files on node-inspector and could not find my code.
Can someone check this on Windows and Mac machine?
In Meteor 0.5.4 this has become a lot easier:
First run the following commands from the terminal:
npm install -g node-inspector
node-inspector &
export NODE_OPTIONS='--debug-brk'
meteor
And then open http://localhost:8080 in your browser to view the node-inspector console.
Update
Since Meteor 1.0 you can just type
meteor debug
which is essentially a shortcut for the above commands, and then launch node inspector in your browser as mentioned.
Update
In Meteor 1.0.2 a console or shell has been added. It may come in handy to output variables and run commands on the server:
meteor shell
Meteor apps are Node.js apps. When running a Meteor app with the meteor [run] command, you can configure the NODE_OPTIONS environment variable to start node in debug mode.
Examples of NODE_OPTIONS environment variable values:
--debug
--debug=47977 - specify a port
--debug-brk - break on the first statement
--debug-brk=5858 - specify a port and break on the first statement
If you export NODE_OPTIONS=--debug, all meteor command run from the same shell will inherit the environment variable. Alternatively, you can enable debugging just for one run, with NODE_OPTIONS="--debug=47977" meteor.
To debug, run node-inspector in a different shell, then go to http://localhost:8080/debug?port=<the port you specified in NODE_OPTIONS>, regardless of what node-inspector tells you to run.
To start node.js in debug mode, I did it this way:
open /usr/lib/meteor/app/meteor/run.js
before
nodeOptions.push(path.join(options.bundlePath, 'main.js'));
add
nodeOptions.push('--debug');
Here are additional practical steps for your to attach debugger eclipse:
use '--debug-brk' instead of '--debug' here, because it's easier for me to attach node.js using eclipse as debugger.
add 'debugger;' in the code where you want to debug.(I prefer this way personally)
run meteor in console
attach to node.js in eclipse(V8 tools, attach to localhost:5858)
run, wait for debugger to be hit
when you start meteor in your meteor app folder, you'll see that "debugger listening on port 5858" in console.
On Meteor 1.0.3.1 (update to Sergey.Simonchik answer)
Start your server with meteor run --debug-port=<port-number>
Point browser to http://localhost:6222/debug?port=<port-number>
Where <port-number> is a port you specify.
In your code add a debugger; where you want to set your break point.
Depending on where debugger; is invoked, it will either break on your client or server browser window with inspector opened.
I like to set breakpoints via a GUI. This way I don't have to remember to remove any debugging code from my app.
This is how I managed to do it server side for my local meteor app:
meteor debug
start your app this way.
Open Chrome to the address it gives you. You MAY need to install https://github.com/node-inspector/node-inspector (it might come bundled with Meteor now? not sure)
You'll see some weird internal meteor code (not the app code you wrote). Press play to run the code. This code simply starts up your server to listen for connections.
Only after you press play you'll see a new directory in your debugger folder structure called "app". In there are your meteor project files. Set a breakpoint in there one the line you want.
Open the local address of your app. This will run your server side code and you you should be able to hit your breakpoint!
Note: you have to reopen the inspector and go through this process again each time your app restarts!
As of Meteor 1.0.2 probably the best way for server-side debugging is directly via the new built-in shell: with running server run meteor shell. More info here: https://www.meteor.com/blog/2014/12/19/meteor-102-meteor-shell
I am not sure why it was not working for you.
I am able to use it by following steps on console (Mac).
$ ps
$ kill -s USR1 *meteor_node_process_id*
$ node-inspector &
Above steps are mentioned on https://github.com/dannycoates/node-inspector. It is for attaching node-inspector to running node process.
I wrote a small meteor package called meteor-inspector which simplifies the use of node-inspector to debug meteor apps. It internally manages the lifecycle of node-inspector and hence, the user does not need to restart the debugger manually after some files have changed.
For more details and concrete usage instructions take a look at https://github.com/broth-eu/meteor-inspector.
for meteor 1.3.5.2, run
meteor debug --debug-port 5858+n
n is a non-zero number, this will cause node-inspector use 8080+n as web port.
WebStorm, the powerful IDE free for open source developers, makes it much easier to debug server-side.
I've tested it on Windows, and the configuration was painless - see my answer.
A inspector that solve my issues is meteor server console. Here is the process I followed to install it:
In your project folder, add the smart package server-eval:
mrt add server-eval
For Meteor 1.0:
meteor add gandev:server-eval
Restart meteor.
Download crx Chrome extension file from here.
Open extensions page in Chrome and drag crx file to extensions page.
Restart Chrome.
Check the web inspector out to eval server side code:
In comparison with node-inspector, I have a clearer output.
If you prefer to use nodeJS' official debugger you can call NODE_OPTIONS='--debug' meteor and then (on a different shell) node debug localhost:5858.

Resources