Run RobotFramework tests with Sikuli Library with Jenkins on VM (RDC) - jenkins

I have automation tests based on RobotFramework with SikuliLibrary, which are for Image Compare. I'm using Jenkins to run on external server (VM) the tests.
If I open the VM - image compare script works. The screenshot is created.
If I close the VM session and run the test, there is problem. Here is the log from keyword "Get Match Score":
INFO Could not find C:\Images\image.png
INFO ${scoreFromImage} = 0.0
Is look like, when the VM session is not active (opened), "Get Match Score" cannot take a snapshot from the browser for comparing.
Is there any idea, how to fix this?
The Code:
Compare Process Diagram Image
[Arguments] ${ImageName} ${ImageScore}
${scoreFromImage} = Get Match Score ${ImagesDirectory}${ImageName}.png
${scoreToString} = Convert To String ${scoreFromImage}
${scoreNumberPrecision} = Get Substring ${scoreToString} 0 6
Run Keyword If ${scoreNumberPrecision} == ${ImageScore} Log Successful ELSE Log Fail

Solved:
The VM must be not closed by "X" button. The correct way:
https://support.microsoft.com/en-us/kb/302801
I have .bat file, which contains tscon.exe %SESSIONNAME% /dest:console, after run - the VM is closed correctly.
Also "Jenkins slave jar" must be running.

Running Sikuli Test on VM is possible but need to keep session open. We cannot run Sikuli script on locked PC. When you close VM , it get locked and Test fail to run. Sikuli needs images for comparing and clicking, if session is locked there are no images so Test fail to run.
So how we overcome this ? :
https://support.smartbear.com/viewarticle/85926/
refer this URL for setting . By applying this you can run sikuli Test with minimized window of VM. (Still you cannot close WM window)

Related

Cucumbers with Jenkins and vncserver throws random Timeout execution expired errors

I am new to Jenkins and have set it up with 4 slaves and trying to run Cucumbers (Capybara+Selenium+Firefox) in vncserver(tried xvfb as well) mode. But some of the slave nodes timeout randomly throwing "execution expired (Timeout::Error)" at the line below
Capybara.current_session.driver.browser.manage.window.resize_to(1600, 900)
and in
page.driver.browser.save_screenshot(screenshot_path)
Starting from here all the remaining tests fail. Have tried using the Xvnc plugin in Jenkins as well but still fails. How do I fix this? Should I use a window manager? Will tightvnc use any default Window Manager? Is it related?
My ~/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
Does someone know what is causing the timeout error?
Looks like this happened because it took time for the browser to open at times so we have to wait or assert till the browser loads. Link here: https://sqa.stackexchange.com/questions/15345/selenium-webdriver-sometimes-fails-to-connect-to-the-browser-when-running-tests

How to enter chroot on Jenkins

Hi i am trying to automate the process of sync and build chromium builds on a Jenkins server
http://www.chromium.org/chromium-os/quick-start-guide
./chromite/bin/cros_sdk --enter
i am trying to run something like this ,the desired output is expected to be a chroot prompt with a changed home directory, I have a Jenkins slave and when i do these steps manually, i am able to enter chroot without any issues and it provides me with the changed home directory and the path shows up where i need it to be for the next step ,
But when i roll this into a Jenkins Execute Shell on the same machine and same credentials, it is not able enter chroot,
./chromite/bin/cros_sdk --enter --log-level=debug
15:59:05: DEBUG: Cache dir lookup.
15:59:05: DEBUG: Configured cache_dir to '/media/1TB/home/qcaswnbu/jenkins1/workspace/Brillo_trial/.cache'
This is what i get in Jenkins
Manually though
./chromite/bin/cros_sdk --enter --log-level=debug
17:27:05: DEBUG: Cache dir lookup.
17:27:05: DEBUG: Configured cache_dir to '/media/1TB/home/qcaswnbu/jenkins1/workspace/Brillo_trial/.cache'
17:27:05: DEBUG: Configured cache_dir to '/media/1TB/home/qcaswnbu/jenkins1/workspace/Brillo_trial/.cache'
i get an extra line with the same message , could there be a chance its quitting half way through when it is initiated from Jenkins job ?
any input is greatly appreciated.
Thanks
Prem
when you run cros_sdk by itself, it expects an interactive prompt. i imagine Jenkins has no terminal attached (by design) which means trying to use it that way doesn't make much sense.
we've designed the tool so it can easily be scripted. if you have some command you want to run inside of the chroot, simply pass it as an argument:
$ cros_sdk -- ls /
bin build dev etc home lib lib32 lib64 ....
i think that should get you everything you need.

Unable to get JSCover and PhantomJS to run Jasmine test on Cloudbees

I am currently trying to run JSCover in web server mode to determine the coverage of my Jasmine tests that are executed in the PhantomJS headless browser. I am also using grunt+nodejs to kick off the tests.
The code I use in my gruntfile to start the JSCover server and execute phantomJS is:
// Start JSCover Server
var childProcess = require('child_process'),
var JSCOVER_PORT = "43287";
var JAVA_HOME = process.env.JAVA_HOME;
var jsCoverChildArgs = [
"-jar", "src/js/test/tools/JSCover-all.jar",
"-ws",
"--branch",
"--port="+JSCOVER_PORT,
"--document-root=./",
"--report-dir=target/",
"--no-instrument=src/js/lib/",
"--no-instrument=src/js/test/",
"--no-instrument=src/js/test/lib/"
];
var jsCoverProc = childProcess.spawn(JAVA_HOME + "/bin/java", jsCoverChildArgs);
// Start PhantomJS
var phantomjs = require('phantomjs'),
var binPath = phantomjs.path,
var childArgs = [
'src/js/test/lib/phantomjs_jasminexml_runner.js',
'http://localhost:'+JSCOVER_PORT+'/src/js/test/SpecRunner.html',
'target/surefire-reports'
];
runner = childProcess.execFile(binPath, childArgs);
runner.on('exit', function (code) {
// Tests have finished, so clean up the process
var success = (code === 0) ? true : false;
jsCoverProc.kill(); // kill the JSCover server now that we are done with it
done(success);
});
However, when I run the web server on a Jenkins node in cloudbees and then run phantomjs against it, I get one of the following errors:
Some tests start to run, but then the process fails:
A spec : should be able to have a mock lo-dash ...
Warning: Task "test" failed. Use --force to continue.
Aborted due to warnings.
Build step 'Execute shell' marked build as failure
Recording test results
Finished: FAILURE
PhantomJS is unable to access the JSCover server:
Running "test" task
phantomjs> Could not load 'http://127.0.0.1:43287/src/js/test/SpecRunner.html'.
Warning: Task "test" failed. Use --force to continue.
For the second error, I have tried to use different ports and hostnames that I set (e.g. 127.0.0.1 or localhost for hostnames, and 4327, 43287, etc. for ports). The ports are not being dynamically set at build time - I have them hardcoded in my grunt script.
Any thoughts on why the errors above might be occurring or why I am having issues running and accessing the JSCover server on a Cloudbees Jenkins node (but never on my local machine)?
So when you execute JSCover with any process, it takes time to be up. If we expect it to be up earlier that it is, the errors are bound to come.
Quoting from the great article: http://blog.johnryding.com/post/46757192364/javascript-code-coverage-with-phantomjs-jasmine-and
Now that I had a code coverage tool that met all of my requirements,
the last part was to get this code to run as part of our Jenkins build
(which utilizes a grunt script). This was easy to get running, but I
encountered two errors that consistently broke my builds:
Sometimes phantomJS would fail to connect to the JSCover server
Sometimes phantomJS would connect to the server, but then give up executing my tests at a random point during the run.
These were really weird issues that only occurred on my team’s Jenkins nodes and were hard to diagnose - even though they turned out to be simple fixes.
For issue 1, that error was the result of my grunt script not waiting for JSCover to start before I executed phantomJS.
For the second issue, it turns out that my team was using a special jasmine test runner to help with producing XML files after tests completed. The problem with this file was that it had a function that waited for Jasmine to complete its execution, but utilized an extremely short timeout before it gave up running the tests. This was a problem with Jenkins + JSCover because it took a longer time for the tests to load and run now that they had to be loaded from a web server instead of straight from the file system. Fortunately, this fix was as easy as increasing the timeout.
I would say that you need to wait for a while after spawning JSCover - in the past I have done things with webdriver when I have spawned, and then waited for it to be available (ideally you can look for a response and sleep, repeat, until the spawned process is ready).
Ie look for a valid http reponse from 127.0.0.1:43287 before continuing (whatever "valid" means that the server is up).

Jenkins accessing Window Server

I have the following problem: I have an ANT-task in Jenkins-CI that (apparently) needs access to OSX' window server (it needs to show a window). After doing some research, it appears that only the currently logged in user and the 'root' user (or SUDO) can access OSX' window server.
The ANT task (Adobe ADL) is one that actually 'runs' a build, so it has to popup a screen.
I'm on a macBook running OSX 10.7.something (Lion), Jenkins 1.487, Ant 1.8.4.
What i have tried so far:
to start with, tried the 'barebone' < exec > task to invoke ADL. Works, but getting error that means that Jenkins running as daemon (with homedir /Users/shared/Jenkins/Home) cannot access OSX' Window Server.
Run Jenkins as myself, by changing USER_NAME, GROUP_NAME, JENKINS_HOME in the jenkins launchd.conf file: https://wiki.jenkins-ci.org/display/JENKINS/Thanks+for+using+OSX+Installer
this gives a lot of errors/trouble, which i tried to solve in communication with the creator of the Jenkins CI but, unfortunately to no avail.
Try to have Ant run an < exec > task (running a shell script) in which i try to sudo with a password using this sneaky way of passing a password to the stdinput: echo < password > | sudo -S < command > which is really bad, but as i'm running Jenkins locally (not reachable from the outside of my LAN) it's np.
Tried to have Ant run an < exec > task, using a 'redirector' with as inputstring my password. also superbad, but yea, i just want it to work. which it did not.
Tried a Jenkins SSH plugin: didn't work. I could, however, SSH to my own localhost using terminal, thing is, i don't know what the Jenkins SSH was trying to do (how can i figure that out anyway?) so i don't know why it wouldn't work.
Tried to have Ant run an SSHEXEC task (which, after some hours, finally worked. Ant for mac is borked, something with optional .jar tasks not being re-named correctly or something) but i'm getting a "com.jcraft.jsch.JSchException: Auth fail" which i googled for, and can't seem to resolve. only applicable solution is to have sshd accept password auths, did that, still got the same error.
I think what i want to accomplish was NOT worth the 2 days that i spent so far on this problem, although i learned a lot. However, i just want this to work and will not accept defeat, yet :)
My question: have you had to solve a similar problem, how did you go about it? are there any other methods i can try to solve this problem? Is there a method mentioned that should JUST _WORK_ and i did something wrong?
[edit] I have decided to go with the Jenkins standalone app, as i think (for me) this is a nicer solution in total, as my laptop is not a build server. Also, the Jenkins app can start at startup so it actually acts as a local server.
Just a quick guess: if you don't want the interactivity of the script, and the script can do without it, you can try to set the headless mode on the java command-line:
-Djava.awt.headless=true
I have decided to go with the Jenkins standalone app, as i think (for me) this is a nicer solution anyway, as my laptop is not a (headless) build server. Also, the Jenkins app can start at startup so it acts as a server too.

Jenkins fails to execute while running as winservice

I am able to run my script successfully from jenkins when jenking is opened using war file.
If set the jenkinks as winservice my script is failing in middle.
I am trying to run a start.bat file from jenkinks, this bat file calls a java class. again this java class uses bat file to run a plink command.
Execution stops at this stepsif jenkinks is running as winservice and also I can't view the output as it is running in background.
Is there any way to make jenkinks behave normal while running as winservice
Thanks
Try this:
1. Go to services (hit windows key, type "services", select "Services" from the list of matches).
2. Find the Jenkins service and open it's properties
3. Switch to Log On tab
4. Change the service to run as you, instead of local system user.
5. Restart service.
Alternative is to fix local system user account (probably environment variables) so it works as local system user.

Resources