How to trigger test using Jenkins with display

Best practices, code snippets for common functionality, examples, and guidelines.
BikashTripathy
Posts: 3
Joined: Fri Jul 15, 2016 1:19 pm

How to trigger test using Jenkins with display

Post by BikashTripathy » Fri Jul 15, 2016 3:00 pm

Hi,

I am automating a standard desktop (.Net) application. I am using Jenkins to trigger the test as scheduled locally on my Windows 7 machine.For which I am building my test and successfully able to generate the .EXE file using Jenkins.

I am executing the .EXE file using windows batch command where in the 1st step of the test it will try to launch the application and then will try to login to it and continue with the other tests but it seems as it is running in command line (without a desktop view) my Ranorex is not able to find the component for AUT which in turn failing all the subsequent steps.

Console Output :
C:\Program Files (x86)\Jenkins\workspace\Clone_App_Automation>cd C:\Program Files (x86)\Jenkins\workspace\Clone_App_Automation\App_Automation\bin\Debug
C:\Program Files (x86)\Jenkins\workspace\Clone_App_Automation\App_Automation\bin\Debug>"App_Automation.exe"
[2016/07/15 11:08:04.424][Debug ][Logger]: Console logger starting.
[2016/07/15 11:08:04.463][Info ][Test]: Test Suite 'App_Automation' started.
[2016/07/15 11:08:04.466][Info ][Test]: Test Module 'LaunchApp' started.
[2016/07/15 11:08:04.477][Info ][Application]: Run application 'C:\Program Files (x86)\.....\DotNet\AppDotNetLauncher.exe' with arguments 'PATCH' in normal mode.
[2016/07/15 11:08:06.576][Success][User]: App Logon window launched successfully
[2016/07/15 11:08:06.603][Info ][Screenshot]: Data logged: System.Drawing.Bitmap
[2016/07/15 11:08:06.603][Success][Test]: Test Module 'LaunchApp' completed with status 'Success'.
[2016/07/15 11:08:07.090][Info ][Test]: Test Case 'LoginToApp' started.
[2016/07/15 11:08:07.090][Failure][Test]: Test Case 'LoginToApp' completed with status 'Failed'.



Is it possible to launch my AUT through Jenkins in desktop mode (without display- not in command mode) so that everything will work fine ? If it is then How can I achieve that ?
Compose message

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to trigger test using Jenkins with display

Post by Support Team » Mon Jul 18, 2016 12:23 pm

Hello BikashTripathy,

Welcome to the Ranorex Forum.

Ranorex requires an active user session in order to be able to access the UI elements. During test execution, the corresponding machine must not be locked because otherwise Ranorex has no access to the Windows UI. If a RDP connection is used, you have to make sure that the RDP-Client is not closed or minimized, which also causes a locked UI.

Please have a look at the requirements for remotely working with Ranorex.
Alternatively, you could use the following workaround to keep the remote machine unlocked.

If you need more information, please do let me know.

Sincerely,
Johannes
.
Image

BikashTripathy
Posts: 3
Joined: Fri Jul 15, 2016 1:19 pm

Re: How to trigger test using Jenkins with display

Post by BikashTripathy » Mon Jul 18, 2016 1:36 pm

Hi,

Thanks for the response.

Ranorex is running on an active user session on my local machine where the system was neither locked nor on sleep mode.So I don't think this is the cause.

Please check the attachment for the Build setup to run windows batch command.

Please suggest me if anything is wrong or missing in the setup.
Attachments
Jenk.jpg
Windows batch command
Jenk.jpg (104.09 KiB) Viewed 3744 times

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to trigger test using Jenkins with display

Post by krstcs » Mon Jul 18, 2016 2:45 pm

Is the Jenkins SLAVE running as a SERVICE?

If so, this will not work. The Jenkins SLAVE MUST be started at the USER level that the test will be run at, so it must be started by the logged-in user account.
Shortcuts usually aren't...

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: How to trigger test using Jenkins with display

Post by Martin » Tue Jul 19, 2016 11:02 am

I remember having the same issue and I finally resolved it with Registry change.

I hope this is the correct parameter to set as it was some time ago:

1) Open regedit.exe
2) Navigate to Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System
3) Add the following new parameter (right click -> new ->DWORD (32-bit) Value) "DisableLockWorkstation" with value "1"

And disable the screen saver as well

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to trigger test using Jenkins with display

Post by krstcs » Tue Jul 19, 2016 3:21 pm

If you are on a domain that doesn't allow you to keep the desktop unlocked, that registry hack won't work.

If that is the case here, you could use a tool called Autologon. It's a paid tool that I use and it works very well, you can unlock the desktop from the command-line, which is handy for Jenkins batch scripts. (I'm not related to the company that makes Autologon, I just use it and it has worked well for us.)
Shortcuts usually aren't...