How to use python script to automate software installation

I am new to Python. I want to automate the software installation process. The scenario is as follows:

Run the installation file. On the first screen, it has two buttons, then cancel. The next click, it goes to the next screen with two buttons, then, cancel, and some input is required. After the data is provided, it will display a completion or cancel button.

In this, I want to write a python script that will automate this action. He must identify the button by clicking on it, must enter the data where necessary, and complete the installation.

To achieve this functionality

+5
source share
1 answer

As Roing noted, pywinauto is a good choice for a Windows installer. Here is a good video example: http://pywinauto.imtqy.com/

To wait for the next page, use something like this: app.WizardPageTitle.wait('ready')
After installation is complete: app.FinishPage.wait_not('visible')
To enter in the input field: app.WizardPage.Edit.type_keys('some input path', with_spaces=True)
For button clicks, I would recommend click_input() as a more robust method.

If you want to install the application on many computers automatically, you can create a remote desktop or VNC session and run a local copy of the Python script inside that session. Just don't minimize the RDP or VNC window to prevent loss of GUI context. Loss of focus is safe, and you can continue to work on the host computer in a different window without affecting the remote installation.


An example of an easy installation script for FastStone Image Viewer 4.6:

 import os from pywinauto.application import Application fsv = Application(backend="win32").start("FSViewerSetup46.exe") fsv.InstallDialog.NextButton.wait('ready', timeout=30).click_input() fsv.InstallDialog.IAgreeRadioButton.wait('ready', timeout=30).click_input() fsv.InstallDialog.Edit.Wait('ready', timeout=30).type_keys(os.getcwd() + "\FastStone Image Viewer", with_spaces=True) fsv.InstallDialog.InstallButton.wait('ready', timeout=30).click_input() fsv.InstallDialog.FinishButton.wait('ready', timeout=30).click_input() 
+7
source

Source: https://habr.com/ru/post/1210901/


All Articles