How To Build a Web Bot in 2 minutes
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.
- 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
PATHenv variable :
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:
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.
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.