KeepSessionActive batch script is not working while calling through jenkins pipeline

Ask general questions here.
palvirani
Posts: 11
Joined: Fri Mar 27, 2020 11:51 am

KeepSessionActive batch script is not working while calling through jenkins pipeline

Post by palvirani » Thu Sep 24, 2020 8:39 am

Hello Team,
I have designed a jenkins pipeline for running Ranorex automation testcases for desktop application. In this, I am running the KeepSessionActive.bat to keep the session active. But instead of running successfully, It is showing the below pattern:
1. In first iteration, Application opens but not able to identify any element.
2. In second iteration, test case runs successfully.
3. Third iteration onwards, script fails with black screen in the screenshots.

Regards,
Palvi

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6553
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: KeepSessionActive batch script is not working while calling through jenkins pipeline

Post by odklizec » Thu Sep 24, 2020 9:04 am

Hi,

I'm personally not using KeepSessionActive, so I can't comment that. Have you examine this post?...
viewtopic.php?f=20&t=11111&p=44803
I'm using LogonExpert on all our VMs and it works quite nice. It keeps the VMs open and logged in.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

palvirani
Posts: 11
Joined: Fri Mar 27, 2020 11:51 am

Re: KeepSessionActive batch script is not working while calling through jenkins pipeline

Post by palvirani » Fri Sep 25, 2020 8:06 am

Hello,

I am already using this below script. Given as solution in the above mentioned link. but its not working while calling from jenkins
Solution #2
Create a batch file on your remote machine and insert the code below:
Save this batch file on the desktop of your remote machine and name it ‘KeepSessionOpen.bat’. If you need to disconnect the remote session, you can now simply run this batch file using administrator rights and your remote machine will remain unlocked.

KeepSessionOpen.bat

for /f "skip=1 tokens=3" %%s in ('query user %USERNAME%') do (
%windir%\System32\tscon.exe %%s /dest:console
)

But it

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6553
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: KeepSessionActive batch script is not working while calling through jenkins pipeline

Post by odklizec » Fri Sep 25, 2020 8:17 am

Hi,

As I mentioned, I'm not using this workaround to make the machine alive, so I can't comment why it does not work if called form Jenkins. It may be blocked by UAC or GOP, or something completely different? Have you tried to find a solution on Jenkins-related forums (or google it)?

It's just a workaround, which may, but may not work. So you should not rely on this solution and rather to find something more reliable, as for example the mentioned LogonExpert, which does exactly what it advertises ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

doke
Posts: 15
Joined: Fri Mar 29, 2019 2:33 pm

Re: KeepSessionActive batch script is not working while calling through jenkins pipeline

Post by doke » Wed Oct 07, 2020 4:58 pm

this script works ! ( i'm using the same)
The black screen tells me their might be screensaver kicking in in after some time.

Make sure you disabled all kind of screensavers / power saving stuff

You could use some additional powershell scripts which are started at logon,
it does minimal mouse move and use scrolllock key to emulate a user being active (when possible with your sut) :

Add-Type -AssemblyName System.Windows.Forms
Clear-Host
Echo "Keep-alive with Scroll Lock...and mouse move"

$WShell = New-Object -com "Wscript.Shell"

while ($true)
{
$WShell.sendkeys("{SCROLLLOCK}")
Start-Sleep -Milliseconds 100
$WShell.sendkeys("{SCROLLLOCK}")
$Pos = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) + 1) , $Pos.Y)
Start-Sleep -Milliseconds 100
$Pos = [System.Windows.Forms.Cursor]::Position
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((($Pos.X) - 1) , $Pos.Y)
Start-Sleep -Seconds 240
}

( do you have auto login enabled as well ? which means jenkins node connects after reboot )