I’ve recently been learning Python. This has been a pleasurable experience! Not since I was first making a computer do what I say with code has it been just so much fun to make things. I’ve been playing with lots of different things to do with Python, mostly centered around the idea of automation. This is what led me to Selenium.
Selenium is a technology used to programtically control a web browser. It is useful for testing web sites, and that is exactly how I intend to use it. Right now I’m trying to understand how to structure the tests themselves into a cohesive suite. How I learned Python was rather loose, so now that I want to build a tool I want better structure.
Once I have the test suite structure understood, the way to go is to use the page object model. I’ve seen some developers disparage this pattern as bloat, but I see things differently. I see the benefits of putting the page specific knowledge in a page specific class. The page doesn’t need to know what a valid test is, it just needs to know what it can do. That is exactly what page objects allow.
My goal is to create a test that will verify a web site after a large processing operation. The site I am supporting uses a decoupled CMS which occasionally requires a full re-publish of all the pages in the site. This process is to be automated and thus I want an automated test to verify the process has not damaged the site. I want it to email me with the results of the tests. Selenium and Python are well suited to this task, specially because the supplied automation code for the publish process is already in Python.
To date, I’ve done many individual tests, including verifying form submissions function and crawling a site to gather links. I’ve used Selenium for the crawler instead of the requests library because of the use of some Angular components on the site. I need to be able to crawl everything. Selenium is quite the toolkit for this job.