Unable to open GUI Application through Jenkins - jenkins

I'm new to Jenkins, I've created a Jenkins freestyle job used necessary plugins to invoke desktop application. When I execute the job with user credentials, I cannot see the application but application got up and logged on with user credentials. I'm doing GUI Automation which causes failures all the times when I try to run the job.
I created a batch file on HOST, calling the batch file through Jenkins. I have tried injecting the environment for job. I have enabled interactive services and Jenkins-slave on HOST machine. I tried to change NT/System user to Specific user. I enabled interactive services in both conditions. I'm not sure what I'm missing here. Do I need to install anything else, so far I have Jenkins-slave.exe on my HOST, I managed to generate executable Jar file using that.
Any help on this will be appreciated.
I'm calling the batch file, Jenkins cannot find the application opening apparently, it returning error as None type Object(Python) as described in screenshot.errors on Jenkins Job execution

I had a similar issue when I was trying to run Selenium UI Test on Windows Slave.
When the Slave is connected to Windows as a Service, then it does not bring up the application in foreground. It runs only in background even if you enable the service to interact with the desktop.
I had to change my browser to headless browser and then my test cases were passed in background mode.
My Old Question

Related

UI issues while executing UFT test via Jenkins

I am having Jenkins running as a service and have a job to execute UFT tests on a remote slave. As part of the pipeline I am required to un-install our product, restart the slave, install the product (latest version) and start the test execution.
Since UFT tests need a dedicated UI, I am trying to launch a mstsc connection to the test VM from a temp VM. But since Jenkins is running as a service the mstsc process runs as a background process on the temp VM. Due to this UFT tests don't get a dedicated UI and some of the tests fail.
Tried running Jenkins using the war file instead of service. But after 30-40 mins or so the master slave connection drops.
Any workaround / tweak would be appreciated.
you need to run your jenkins remote agent(war) as a normal Process and not as a service, otherwise, as you mentioned there is no Desktop for them.
My Proposal:
Make sure the jenkins remote agent is running as a normal OS process (on both VMs). You can have a Windows Scheduled Task that launches this Process on Logon and Checks every 5 minutes if it is still alive (if not restarts it)
After the Temporary VM (Let's call it a Gateway) woke up your Test VM, the Test VM should execute a tscon command which will redirect the currently active RDP Session to the console (the Physical Monitor - which on Virtual machines well it's virtual). This will help you having your UI Session alive until the next restart, without having to bother about the Gateway
tscon here. Example: tscon rdp-tcp#1 /dest:console This can be solved again with a Scheduled Task which is executed At Logon (waiting a few Seconds just to make sure)
Have Caffeine.exe or MouseJiggle.exe running in the background as Processes (also launched at Logon) on your Test Computers to make sure the SCreen is never Locked or any Screen Saver is activated. Both tools are free.
If your Jenkins Connection drops that is a different issue has nothing to do with UFT. In my case this combination works perfectly fine. It is also easy to automate the installation of these things. Windows Batch and Vbs can do all these things for you. (Putting the mentioned tools to your %PATH% and creating Scheduled Tasks Programmatically)
** Bonus Tipp: In order to avoid a taskkill java.exe command killing your remote agent, you can simply rename the java.exe of your jvm to jenkins_remote_agent.exe and use that as your jenkins remote agent executable
UFT requires an interactive session for some Win32 operations.
In the Tools ⇨ Options menu, select General ⇨ Run Sessions there you will find an option to Enable continued testing on locked/disconnected remote computers, this may help in your case too.

Webdriver with Jenkins

Selenium test (testNg) with mvn test from jenkins ,
I cant view the action performed on the browser, it is possible to view the real browser opened and performing action?
I suggest using SeleniumGrid.
You can then let the test run on a node, where you can see all the browser actions. For demonstration purposes, distributed and independent testing I did similar with teamcity for a regression-test project.
Basically there are two steps to setup the environment:
Start the grid for example as background-service.
Start a node which is running within a logged on user context (also as Service or autorun)
optional: Start another node for running tests in background
In your tests the creation of the the WebDriver instance changes like this:
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
Here a link for more details to setup the Grid2: https://github.com/SeleniumHQ/selenium/wiki/Grid2
No. In typical setup, tests from Jenkins run on randomly available node. You don't know which node is available at a given point. Also typically Jenkins nodes tend to run headless browsers (like phantomjs) since they don't have displays.
Jenkins tests are meant to be run without any manual intervention, like on nightly basis for example. You develop tests locally, see how they run in a real browser and then push it to your main suite so that Jenkins can run it for you. If you want to run tests from Jenkins and view test running live then look for paid solutions like saucelabs or browserstack.
You can using BrowserStack. We have recently released a Plugin that allows you to view your test results right inside Jenkins. It's a paid tool of course :(
In Windows you should not install jenkins as windows application (because in this recent version, Microsoft decided to give services their own hidden desktop even you enable the functionality "interact with desktop" in jenkins service), you may have to deploy it from a war file as follows:
1) Download jenkins.war from Jenkins official site
2) Deploy it by the command prompt : java -jar {directoryOfJenkinsFile}/jenkins.war
3) Now you can access jenkins administration on http:// localhost:8080
Hope that helps you !

When selenium test runs by Jenkins and nUnit, the browser doesn't come up however there are valid results

I would say that my problem rather lack of information and I need some confirmation than a real problem. It seems somebody else had similar question question.
I put together a machine (Windows Server 2012R2) for POC reasons where a Jenkins installed and it executes Selenium UI tests using nunit. The nunit tests are generated by Specflow.
I could do:
install jenkins
jenkins run by a valid user not by Service account
set up jenkins properly
it can pull the source code from TFS-GIT
it can compile the C# solution
it can execute the test project
the test results are correct
Selenium plugin installed on Jenkins but I don't think it is used in this case because the text execution is about executing nunit and it deals with everything else.
At the moment I don't need the capability to delegate test execution to other Jenkins slaves or machines because the Jenkins does have only one compile task. Compiling, executing and test running can go parallel, the machine able to deal with it.
But, when I log in the server where the Jenkins runs and I watch what happens during CI build (compile and test execution) I can't see that the browser (Firefox) starts, however, the test results and the logs show that a browser was executed.
What I did so far:
jenkins runs as service, the account is an existing account
If I remote to the machine with the account which is set up for the service, then I can't see the browser will be executed, however, the log shows that something had happened.
My question is that, what the hack is happening when my tests are executed by Jenkins? If I execute the command which is used by Jenkins from console on the same machine then I can see that Firefox starts, does what is programmed in the tests and the results are in the result.xml. Can I accept the result as valid result? Can I somehow set up Jenkins the way the browser really executed (I can believe it when I see it :) )?
I think this is because you run Jenkins as a service. Services do not show up in desktop. Workaround is to run Jenkins or slave from CMD.
Jenkins windows slave service does not interact with desktop

How to run jenkins job as a system user?

Rightnow, my jenkins jobs are run by Tomcat Server user.
I wanted it to run as User 'Admin', so i tried creating a slave and
added my same jenkins machine as the slave.
I have also added this as a windows service, and have confiured the
Admin user/pwd in the Logon Tab.
But still, when i run a job which executes the UI tests, i'm not able
to see them running in the firefox but it runs and the screenshots
are captured!
Are you asking how to have Jenkins spawn a process in your session that you can see at the monitor?
Have a look here: Open Excel on Jenkins CI, replace excel with whatever you are launching.
If you use jenkins as windows service, it won't allow GUI execution.
It only allows backgound running jobs.
If you want run UI test then stop your jenkins service , use some other way to connect your slave.

Jenkins can't connect to window server - not enough permissions

I've just installed at local a Jenkins server in order to execute some tests using Selenium Webdriver.
When I execute the tests, the initial steps are executing well (maven calls, access to repo,...) but when the first selenium step have to be executed, I get this error:
(java.lang.InternalError: Can't connect to window server - not enough permissions.)
What permissions are refered?
I'm executing from my main user in my computer in a MacOSX.
I've looked information in jenkins site and google, but I can get anything.
Add JVM options -Djava.awt.headless=true
On the instance I use, the "JVM Options" field is only visible from the "Advanced..." button under the Launch Method sub-heading.
Have you tried adding a different JDK to your box and using that for your build? I had a similar issue with a Jenkins build job on my mac and was able to correct it:
Jenkins build failed on OSX

Resources