Does the Powershell command “sendkeys” work in Jenkins? If not, is there an alternative method?

55 views
Skip to first unread message

Jenkins Johnny

unread,
Sep 14, 2016, 4:58:17 AM9/14/16
to Jenkins Users

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.

Reply all
Reply to author
Forward
0 new messages