Build a web bot in 2 minutes 🤖

MECHERI Akram
2 min readMar 18, 2021

--

There is a ton of repetitive tasks that we can automate thanks to bots, in this article I’ll show you the easiest and the fastest way to build a bot using Python and Selenium 🚀🚀🚀.

1 . Download the Chrome Web Driver 🔨 :

Chrome web driver makes it possible to manage the browser using any programming language, here we will use Python.

  • First, download the webDriver here.
  • Second, unzip the chromedriver.zip file and copy the webDriver to a specified location: cp chromeDriver /Library/webdrivers/chromeDriver
  • Third, add the location of the webDriver to the PATH env variable :
export PATH="$PATH:/Library/webdrivers/"

2. Install the Selenium package for Python 📦 :

pip install selenium

3. The Python code 🐍 :

To execute the Python code and run the bot use the following command:

python simple-selenium-bot.py

The usage of the sleep()method is very common in these types of bots, it allows you to wait for a request to be sent or for the UI to be refreshed before continuing the execution of the program.

Screen recording of the bot

This is a simple bot program that shows you how Selenium works, there is a lot of real-world use cases out there to implement in order to gain time or productivity using Selenium, here are some bot ideas I worked on previously :

  • Checking the availability in a booking system.
  • Checking out the availability of a high demanding article in a marketplace.
  • End-to-end tests of a web application.
  • ….

That’s it, if you find this article interesting don’t hesitate to let me a comment or hit the 👏 button below.

--

--

MECHERI Akram

Lead Software Engineer working across multiple technologies and frameworks. Always willing to challenge my problem solving skills.