Selenium is a Python package, that is used for automating tasks in browsers, web scraping, testings, and building bots. It basically controls the web browser in an automated manner.
Although we'll discuss Selenium in Python, Selenium can be used with any programming language like Java, C#, etc. It is a widely used package nowadays for testing and web scraping purposes.
Selenium can be used with any browser like Chrome, Firefox, Safari, etc. All we need is a web driver for a browser we want to use, which can be downloaded easily. Those drivers make it possible to automate browsers through the selenium program.
Installing Selenium
Make sure python
and pip
is installed and then lets run the following command in a terminal,
pip install selenium
Now selenium will be installed in our machine.
Writing first selenium program
Now let's open any text editor and create a new file named app.py.
Import Selenium
from selenium import webdriver
Instantiate Selenium
browser = webdriver.Firefox()
Note that we need a browser driver to instantiate any web browser. In my case, I'm instantiating the Firefox browser.