Selenium Python Basics

Chaayagirimon
featurepreneur
Published in
Feb 26, 2022

Selenium is an open source tool used for scraping websites, controlling web browsers and automation of web browsers. It is also written in other languages like C#, Java etc besides python.

Installation:

pip install selenium

Selenium needs a webdriver to interface with a browser. To download the chromedriver:

https://chromedriver.chromium.org/

download the chromedriver according to your chrome version.

You can easily access the HTML of the website by inspecting the page.

You can get specific elements by the class name, tag, name, xpath, css etc.

example commands:

find_element_by_class_name("class")find_element_by_tag_name("tag")

To find the xpath right click on the element and click on copy xpath. You can find css selector the same way.

find_element_by_xpath("xpath")find_element_by_css_selector("css")

Thank you for reading.

--

--