Automated Testing With Selenium WebDriver

Krae Wind
2 min readSep 16, 2021

I was recently tasked with creating automated testing for a web application. The only experience I had with testing was the practice of using test driven development to pass labs for Flatiron School’s Software Engineering course. With Flatiron testing my code directly using rspec for ruby and mocha for javascript, I thought testing the code directly by calling the functions with a certain input and expected output was the only way to test. Turns out, testing is a whole lot more broad that I ever knew! Not only is it extremely diverse, it can be a lot easier than you would think.

The way I am implementing testing after having read up a bit is using Selenium to control the browser and mocha with chai to test for expected results.

After some initial setup, Selenium is almost like an invisible robot we tell to use the broswer just like you and I use the broswer. Find this element, click this element, type this email in this field. It really is just like manual testing a browser. In fact, you can even see the tests unfold on your display as if someone has magically taken over your keyboard and mouse.

A huge benefit of this is obviously it cuts down on complexity by use of abstraction. Another benefit is the cross-browser compatibilty. With very little effort, I can take hundreds of commands, tests and assertions I wrote for Chrome, and use it on Safari.

This has been a high level overview of what Selenium is and how powerful it can be. Next week, we will deep dive into some setup and write our first test to make sure google’s homepage loads properly!

--

--