Selenium is a fun little thing that seems quite complicated and daunting if you’ve never taken the time to dive in, but actually it’s both powerful and easy to understand when you take maybe an hour or two to learn the basics.

In this article, I’ll show you those basics real quick, and hopefully in an easy-to-understand way, as well as some applied examples of how to use them because I always learn better when I know what I can use those skills for.

Setting Up Selenium in 5 Minutes

Selenium can be used in Java or Python quite easily.

I’m a fan of using Python for small scripts, but you can complete the exact same steps with Java under a slightly different syntax.

The setup using Python is almost stupidly simple. You just need to download the driver for your browser of choice (FirefoxChrome) and place it in your working directory. You can also go the route of placing the driver in your PATH variable, but I prefer putting it in your project directory and referencing it from there so you have everything in one place.

Then you run:

pip install selenium

That’s it. Now you can reference it like this:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Chrome('path/to/your/project/chromedriver.exe')

Now you’re in business.

The 3 Components You Need to Know

Selenium is powerful and vast, but there are just three things you need to know to do basically everything you might want to:

  • Finding an element
  • Clicking buttons/entering text
  • Verifying results

#testing #tdd #programming #technology #front-end-development

The  Beginners’ Guide to Automating Websites and Tests With Selenium
1.25 GEEK