Automated testing of my video game with Python (pyautogui)

Опубликовано: 04 Август 2026
на канале: Rose Code
108
0

Not sure of what I should put on this channel, so here's a video of me running some automated test scripts on an educational math video game I just finished making.

It's all automated using a Python module called pyautogui. With pyautogui you can make function calls like pyautogui.click(x, y) to click the mouse at a certain location on the screen. Also pyautogui.screenshot() will create a Pillow/PIL Image object. Then you can detect things on the screen by comparing the screenshot with a certain image using pyautogui.locateOnScreen('image.png') or by looking at a certain pixel in the screenshot using pyautogui.pixelMatchesColor(x, y, (r, g, b), tolerance).

I'm running 3 different scripts to play this edutainment game until the game is over. At the very end of the video, I start a new game manually. I made the automated test scripts to save time and avoid the monotony of repeatedly testing the same things after making changes to my code. The game itself is written with Construct 3 and JavaScript. It's geared toward 5th graders, so that they can learn about mathematical concepts like (x, y) coordinates, x-axis, y-axis, origin, and the four quadrants, while having fun at the same time.