Automating TestStack.White UI Testing in Windows Slave using Jenkins - windows

First of all, I apologize if I am wasting your time, because it looks like a simple step which I am not able to figure out even after some research.
Ok, here is what I am trying to achieve, I have written some UI tests using TestStack.White, I would like to execute this on a Jenkins Slave as different user, since the application behaves differently based on the roles that are assigned to them in Active Directory.
So after doing a bit of lookup on google I found the following links which are relevant to what I am trying to achieve.
http://teststackwhite.readthedocs.io/en/latest/AdvancedTopics/ContinuousIntegration/
How to get Sikuli working in headless mode
Jenkins on Windows and GUI Tests without RDC
It looks like that I have to install TightVNC on Jenkins slave and should connect to slave from Jenkins Master and execute tests on slave.
Which brings me to my first question, how do I exactly achieve this from a Jenkins job?
About logging in as different users, I understand I can use to "autologon.exe" to achieve this. So just wondering how I can do this on the Windows Slave from Jenkins Master. My company doesn't allow SSH to Windows instances (slave machines), I cannot remotely execute SSH from Jenkins Master.
I understand that I may not be looking at this correctly, so any help would be much appreciated.
Thanks in advance for your time and advice.

I am getting ready to do something similar to this but I am building a communication layer into our UI Automation application so that our build machine (our company rolled our own build machine) can send TCP request back and forth. I am going to deploy the UI Automation and the build to a share then start a virtual machine. The build machines template will have a startup script that launches both our applications from the share. Once the virtual machine is started then I am going to communicate with the UI Automation application to tell it to start and it will tell me when its done so I can tear down the VM. I am going to save all the test results out to a share for reporting purposes.
I know this doesn't directly answer your question but this approach is one I have heard about from multiple people working in various automation frameworks.
If I was going to do this in Jenkins I would look into Jenkins plugin system. The plugin system as far as I know uses Java so you should be able to create some type of communication layer and interface with some type of VM. If you don't have the option to start and stop a VM you will need to look into start and stopping processes on a remote machine while masquerading as a user. I know this can be done in C# but I have never looked into it in Java.

Thanks all for your comments and answers, basically this is what I did to get it working for me,
Establish VNC connection with a VNC Client on Jenkins slave, this was done manually not through Jenkins.
Use an app called "Caffeine" to prevent windows from locking out, it simulates a key up event on F15 (every xx seconds) so there is no interruption with testing task in my project.
Launch JNLP connection to the Jenkins Master and "Caffeine" app as a part of windows logon through VNC Connection.
Close out of the VNC connection (not logging off), this was done manually not through Jenkins.
Let the build run as different users using PSExec on the slaves.
This seems to be working fine so far, I didn't reply sooner since I wanted to monitor the jobs for a few days before posting my reply here.

Related

How to Auto-start selenium nodes under Windows

I am trying to automate the startup of my Selenium Grid.
I have the Hub registered as a service, so that starts when the machine starts, but
the literature tells me I can't do the same with the node, because it won't be in a User context, and so I would not be able to get screenshots etc.
I've seen vague hints that you can add something to the registry to start a program, but I'm not really convinced thats what I want.
IT pulls down the servers for upgrades at intervals, and sessions are set to time out after X amount of inactivity, so its a tedious and silly process to open remote desktops to all 6 nodes, in order to log in, then start the process every time.
How do you best manage this?
- Configure the machines to auto-login, and place startSeleniumNode.bat in that users start-folder?
- Add some kind of commandline entry in the jenkins build script that launches the test, to call each of the 6 nodes in turn to start the selenium node (and how would you do that?)
Take a look at AlwaysUp - it allows you to run almost any application as a Windows service including Selenium Grid hubs and nodes.
I've previously created a fairly large Grid infrastructure using AlwaysUp for node management. It's very useful for starting up Grid on boot and lets you specify a user account to run as, schedule restarts at regular intervals and a lot more.

Cross-machine UI automation frameworks?

Good time of day,
Tried to google it but haven't found an answer - are there any free or paid UI automation frameworks that can give me ability to automate an applications that installed on different computers but communicate with each other?
Ideally what I want is:
Do something on Machine A
Wait for event on Machine B
Do something on Machine B after event occured
Wait for event on A
I'm a bit lazy to write and run different tests on both machines (e.g. test1 with steps 1 and 4 and test2 with steps 2 and 3 so I'm looking for other solution.
Perhaps you could set something like this up using Jenkins: http://jenkins-ci.org/
One idea for how it might be done:
The Jenkins master node launches a job on Machine A
The program running on Machine A contacts the master node (via the Jenkins REST API) to launch a job on Machine B
Machine A then starts polling the master node, waiting for Machine B's job to go into a completed state
Machine A continues with its work once the Machine B job is complete
Note that you might be able to dispense with the need for a third machine on which to run the Jenkins server software, and instead make your A or B machine serve a double role as the Jenkins master node as well as a job runner.
This approach means you'd end up with code specific to the Jenkins API code in the processes you're launching on A and B, but nonetheless it might be fairly quick to implement.

Launch User App with GUI from Launch Daemon

I've got a Launch Daemon that runs as root outside of the user context. This Daemon is always running and monitoring a server. On occasion, my Daemon will get a command from the server telling it to display something to the user. Obviously I can't do this from a Launch Daemon since it's not running in a "WindowsServer" environment - so the other option is to spawn a separate process for each user that has access to be able to display a GUI.
One option I have is to make a Launch Agent and have the OS start it up for me. The launch agent could then communicate with the Launch Daemon to determine when something needs to be displayed.
The problem is this though: the server will sometimes provide updates of the actual binary files. So the server would send the Launch Daemon a series of files which it is expected to copy out on top of the existing files. If I have a Launch Agent running, how can I shut it down so that the agent itself can be updated? Likewise, how could I start the Agent back up after the update is done?
Off the cuff, I would say that you should arrange a way for your daemon to request the launch agent to exit on demand, the same way you would arrange for it to launch on demand. Once you know the agent has exited, your daemon can proceed with the update.
Note that your agent probably should not live forever, and it should definitely not be polling the daemon for work. Instead, you should rig it up so that, when the daemon tries to connect to the agent, launchd launches the agent. You could do this by having the daemon connect to a Unix domain socket registered on behalf of the agent by launchd, for example.
You might do better to look at how Google's UpdateEngine handles software updates. I believe it too has a launch daemon perform the app updates. Since this is already working on many computers, its solution to software update problems is a proven one. (Sparkle's solution is thoroughly proven, as well, but it relies on user interaction, which you seem to want to avoid.)

How to identify users which are connected to a windows server via remote desktop

At my workplace, we have lab machines that we use to do our testing.
The standard procedure to reserve a machine for testing was to walk around the office to make sure that no one was using the machine.
This is highly inefficient and time consuming.
At first, I set up a web page where people could reserve the lab machine but nobody was keeping the page updated so that turned up to be useless.
I finally found a solution using Microsoft log parser and wanted to share it to the stack overflow community.
It is a batch file that runs on the machine so the user can identify the last users that use the machine and easily IM them to ask if the machine is free.
Is there a better solution to do this?
Use the built-in command qwinsta (Query Win Station) to figure out what sessions (including console) are active or inactive (disconnected) and then act on the given information (creds to krusty.ar btw for linking this already).
If you feel people are abusing the machine in question, refer to rwinsta to nuke their sessions into oblivion...
You will need to install the Microsoft Log Parser
Then create the following 2 files
TSLoginsDetails.sql
SELECT
timegenerated,
EXTRACT_TOKEN(Strings,1,'|') AS Domain,
EXTRACT_TOKEN(Strings,0,'|') AS User,
EXTRACT_TOKEN(Strings,3,'|') AS SessionName,
EXTRACT_TOKEN(Strings,4,'|') AS ClientName,
EXTRACT_TOKEN(Strings,5,'|') AS ClientAddress,
EventID
FROM Security
WHERE EventID=682
ORDER BY timegenerated DESC
TSLogins.bat
echo off
cls
c:
cd "c:\Program Files\Log Parser 2.2\"
logparser.exe file:TSLoginsDetails.sql -o:DATAGRID
Now by placing this batch file on the desktop, the user can see who were the last people to login and contact them by IM to verify if they are done.
How about posting the information from the log file to the website that tells who is currently using the machine as well.
Check and notify when they log in.
Updated the "who is using the machine" page you made prior.
Run a AT job that checks every couple of hours who is on it.
Totally out of the box:
You can install the Software Testing Automation Framework (STAF) on your servers and desktops to manage your tests. It's written in Java, so you can use it on Windows and Unix/Linux desktops and servers.
Using STAF, you can create a resource pool of test servers on which you conduct tests, then write STAX jobs (STAX is a STAF execution framework) to conduct the tests. The job can grab the first available server from the resource pool, run the test, monitor the test status, log results, notify the submitter, then release the server back into the pool when done. If you have multiple people submitting jobs for tests, STAF will manage the queue of requests and satisfy them as they came in. Users can either monitor the job from their desktop, or you can set up email alerts to notify them when the test is complete.
I'm not sure if I understand you, but there are a set of command line tools to deal with terminal server sessions, and there's also a Windows API to do the same if you need to do this from a program.
Since it sounds like you're a microsoft shop, you can set up the machines as resources in outlook/exchange and reserve them that way.

Run UI SeleniumRC tests as a part of CI process

I'm trying to setup CI environment for QA department. They use SeleniumRC to run UI tests in IE and FF browsers to test some web application. I had a success configuring it to run as a windows service as described here. However when i run the test it hangs. I can see iexplore.exe process spawned by Selenium service in the process list but nothing more happens. No browser window appears, no entries in the windows event log. I did a lot of googling and as fas as i understand the problem is interaction with desktop. I tried to run the service under SYSTEM account with "Allow service to interact with desktop" check-box set as well as under a regular user account with local admin permissions. So my question is if it's possible at all?
In our organization we have a continuous integration server (Cruise Control) running the build including Selenium RC tests. The CI server is run as a Windows service (on MS Windows 2003 Server) and Selenium tests are just part of the test suite.
That is quite a straightforward setup and frankly I see no reasons for giving up with it. Currently in our setup the Selenium server (and client) is started directly from the tests (however we used to have Selenium as a separate service).
In Java code (actually in the super class of all web tests) we do something like:
// to start the server
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.set(...) // set the serverHost and port
...
SeleniumServer server = new SeleniumServer(config);
server.start();
// and then to start the client
Selenium selenium = new DefaultSelenium(serverHost, port, "*firefox", "http://www.google.com");
selenium.start();
selenium.open("http://www.google.com");
// now the browser should be visible for you (if you run it locally, not as a service)
So I would suggest you trying the following (whatever language you are using):
Try to run the Selenium server and client from just a standalone application. The browser should show up as a window. Adjust the settings to your needs (browser type, etc.).
Try to incorporate the code within your test framework (xUnit or whatever). Run them manually. The result should be the same.
Then you can try to have the tests run from the continuous-integration. Run the CI server as a service and let it build your project. The browser wouldn't be visible, but that's not required for the tests to be run, isn't it?
NOTE:
if you wanted to peep what Selenium is doing, I believe it would be easier on UNIX machine. You could point the tests to use the X-server DISPLAY of your choice - a fake one or a true one connected to some monitor.
I'm skeptical about running anything as a windows service that is supposed to interact with a desktop application. Windows services run in their own sandbox; they're not supposed to interact with a user's desktop or its applications. To do so requires special efforts to communicate with the service, so if it is possible at all, I would think there would be some kind of desktop client running as well, acting as a liaison between the browser and the windows service.
I can't tell you it won't work, though, because it is obviously possible if people are blogging about it.
Why does it need to run as a Windows service, by the way? Is that how Selenium has set up their automation, or can you do it without the Windows service? Because I think that would be the shortest distance between two points.
My recommendation would be to have a dedicated machine (or virtual machine) for running Selenium RC. In my experience it's best to let Selenium run interactively rather than in a headless mode.

Resources