Testing with Python and Selenium

There are three kinds of lazy.

Let’s make sure we’re in the last category.

The Selenium library is a workhorse for automating your web browser. I use it to automate data entry and integration testing, but you could do much more with it as long as the task involves your browser. Scrape the DOM? Yes. Click buttons? Yes. Fill out forms? Yes. Handle alerts? Yes. Switch windows? Yes. Want more? Go read the docs. We’re just going to scrape the surface.

  1. From the Windows terminal

  2. Download Chrome Driver

    Make sure to get the version that matches your chrome version.
    What version of chrome do I have?
    Extract the zip and take note of the destination folder. You’ll need the .exe path in the next step.

  3. Open Python and import selenium

  4. Selenium + Unittest

    What is the answer to life, the universe and everything?
    Calculator says 42

  5. Run TestDemo.py from the CLI