In 2022, I went to the Columbus based QA conference QA or the Highway for the first time. This was my first ever work conference, so I was very excited to attend an event with so many people in my line of work. While I don’t recall most of that conference, there is one presentation that still sticks with me.
That presentation, which the name and speaker are lost to me unfortunately, focused on how you can make your automated tests better. One of the ways that was talked about was avoiding stale tests by testing the same page over and over again. While testing the same thing over and over again is kind of part of our job, doing so on the same page with the same content will rarely produce a different outcome. This is when the speaker said that they randomly select a page to perform testing again. They did this for both positive and negative tests. Needless to say, my mind was blown and I had schemes cooking in my brain as to what to do when I got back to work.
When I returned to work the following Monday, I set off to add random page selection to my automation. I ended up having two iterations of it. The first version used an HTML sitemap for a content management system and I used Selenium to gather every page. This worked poorly, admittedly. This is because when a site has around 100 links, it works fast… However if you reach over 5000 pages and links Selenium really gets bogged down. So while I was getting random pages, my tests had an added 30+ seconds to get said random page.
Version two worked so much better. I discovered that there was an xml version of the same sitemap. I then realized I could pull down the xml using an hTTP call and turn it into a List object. I could then use the Random class to select a random page. Flash forward to now, where I still use this code. I even enhanced it further, so I can now feed that method filter paths to specific kinds of pages.
If it wasn’t for QA or the Highway, I would still be dealing with stale tests and hardcoded tests everywhere. I am very grateful that my (former) coworker shared this conference with our team, and that I’ve been able to go for almost half a decade. Maybe some day I could even present there! Who knows!