Reputation: 49
We have hosted our Jenkins server on an RHEL 7.9. We want to connect to the remote windows server from the RHEL box and execute a python program that uses pywinauto package to manipulate a GUI application that runs on the remote windows server for functional tests. Our python script that uses pywinauto is ready and working fine when executed from cmdline on the remote windows server and want to trigger the script from a Jenkins job. Now, Can someone here please let me know the options I should think of to connect to the Remote windows server from RHEL and execute a python script that does GUI automation?
Upvotes: 1
Views: 287
Reputation: 2813
Holla, I have done this recently from centOS 8, This was quite challenging though. Since pywinauto requires active desktop to perform actions on the UI. For this purpose we can not do SSH or similar ways.
Here is how to...step by step.
You can use to do the RDP connection to the windows server using xFreeRDP from RHEL.
xfreerdp /u:username /p:password /v:hostname
Ref.- FreeRDP
Up to this all works smooth here onwards you can not execute the commands on RDP session to trigger the execution.
But windows server is your savior. It does provide you the EVENTCREATE
command which allows you to create event. It will create event on your behalf in your windows server. This command will allow you flexibility for scheduling your job. The events created by this command will be listed in the event-viewer utility of windows. To see the window event created by you, give meaningful message. To create event user should be administrator.
Example -
eventcreate /t INFORMATION /id 1000 /d "Create event in WinMgmt source"
In this step you will have to setup/schedule the job based on event occurred on windows. By right clicking on event and then select option 'Attach task to this event...' or by directly going in to the Task Schedular (another windows utility tool).
a. Open Task Schedular.
b. Right click on root tree node - "Task Schedular Library"
c. Select the option "Create Task..."
d. Popup will open to create Task Fill Name and description of task.
e. Select the checkbox "Run with highest privileges".
f. Go to trigger tab and New button.
g. Select the first dropdown value for "Begin the task" as "On an Event".
i. In the setting section of popup select log type of event.
ii. Source and Event ID values should be similar that you will use in your custom event(step 2 event).
iii. Select other scheduling setting as per your need.
i. Go to Actions tab and click on New button.
j. On the New Action popup, select Action as "Start a program"
k. Select your program (python script) to be executed and parameters if any in setting section.
l. Click OK and test this connection of event and task by firing event from cmd (step 2)
This is almost done now except the one critical part. And that is how to fire eventcreate command from RHEL. You can do that by writing small python code using SSH or paramiko packages.
NOTE's
Upvotes: 1