I've been trying to create a Powershell script in Jenkins that input keyboard commands to test if various fields and quick key shortcuts are working.
For example, I use the following to enter a 'quick key' event that will close the application (alt + X)
Add-Type –AssemblyName System.Windows.Forms
[System.Windows.Forms.SendKeys]::SendWait("%{X}")
This works fine in powershell ise on my desktop, but when used in jenkins it returns the error:
Exception calling "SendWait" with "1" argument(s): "Access is denied"
At C:\WINDOWS\TEMP\hudson3939198379009014854.ps1:9 char:42
+ [System.Windows.Forms.SendKeys]::SendWait <<<< ("%{X}")
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
At first I thought this was a permissions issue, but someone suggested that Jenkins cannot run sendkeys because jenkins is in non-interactive mode, and sending a key is an interaction.
Does anyone know if this is true? And if so, is there an alternative method for testing these quick keys?
For fields I can simply input a $variable.value, but for quick keys that don't have an input, I'm not so sure.