Testing Flash App using PyAutoGui in place of Selenium

Deepak rkm
2 min readJul 29, 2019

PyAutoGui an alternate to Python -Selenium

Its always challenging to test Flash Application using Selenium if the application is not designed in a way to expose the iframe objects and elements or even if the developer disabled the right click on the web page.

There comes the need for the wrapper which allows to use the keyboard and mouse programmatically to achieve the Test Automation in which PyAutoGui helped us to solve our problems to some extent.

we can use Selenium and Pyautogui in parallel to solve the test automation on the application which are built with hidden elements and objects.

Rather beating around the bush .Lets Jump on to use case.

Use case:

Login into Web Application through Pyautogui.

Step1:pip install pyautogui

Step2: pip install -U selenium

Step3:Download Chrome Webdriver and place in your local machine and may be in the path C:driver\\chromedriver.exe.

Note: pyautogui supports python2 and Python3

Lets consider to use Pyautogui to login into the below website http://testing-ground.scraping.pro/login

Image of the website

After loading the above web ,we need to login passing the username and password.Consider we are not allowed to inspect the elements of the page and now we can use pyautogui to best of its use.

The sequence of keyboard action to place the cursor in the Login label is to press tab twice and third tab will place the cursor in the Password input label and fourth tab will place you cursor in the Login button and the Login has to clicked through mouse action Keydown.

Summarising the series of actions to login in to web using the keyboard and mouse are as follows.Considering the application is loaded using the selenium python wrapper.

Step 1:tab

Step 2:tab

Step 3:Input username

Step 4:tab

Step 5:Input Password

Step 6:Tab

Step 7:Click

Lets achieve the above steps using pyautogui

from selenium import webdriver
import pyautogui
brower = webdriver.Chrome(executable_path =”C:driver\\chromedriver.exe”)

def foo():
website_URL =”
http://testing-ground.scraping.pro/login"
brower.get(website_URL)
pyautogui.press(‘tab’)
pyautogui.press(‘tab’)
pyautogui.typewrite(‘admin’)
pyautogui.press(‘tab’)
pyautogui.typewrite(‘12345’)
pyautogui.press(‘tab’)
pyautogui.press(‘enter’)

if __name__ == ‘__main__’:
foo()

After Executing the above you will see the image as successful Result.

After Login Page

Similarly the wrapper can be used extensively for automation testing and for more information,please refer the link https://pyautogui.readthedocs.io/en/latest/

Thank You & Happy Learning…..

--

--

Deepak rkm

proud to be pythonist and aspiring to be sre with AI skills