Getting Started with Selenium

WHAT IS SELENIUM ?

Selenium is a portable framework for testing web applications. Selenium provides a playback tool for authoring functional tests without the need to learn a test scripting language (Selenium IDE).

Selenium Client API

As an alternative to writing tests in Selenese, tests can also be written in various programming languages. These tests then communicate with Selenium by calling methods in the Selenium Client API. Selenium currently provides client APIs for Java, C#, Ruby, JavaScript, R and Python.

PYTHON + SELENIUM

1. Downloading Python bindings for Selenium

Use pip to install the selenium package. Using pip, you can install selenium like this:

pip install selenium

2. Drivers

Selenium requires a driver to interface with the chosen browser. Supported browsers will have their own drivers available. Links to some of the more popular browser drivers follow :

Chromehttps://sites.google.com/a/chromium.org/chromedriver/downloads
Edgehttps://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
Firefoxhttps://github.com/mozilla/geckodriver/releases
Safarihttps://webkit.org/blog/6900/webdriver-support-in-safari-10/

3. Simple Selenium Program

Now you’re all set to start working with Selenium. The first thing you’ll need to do is start the browser:

from selenium import webdriver

EXE_PATH = r'path\to\chromedriver.exe'
driver = webdriver.Chrome(executable_path=EXE_PATH)
driver.get('https://google.com')

Running this will open Google Chrome and navigate it to https://google.com.

4.Conclusion

Selenium is one of the widely used tools used for Web Browser Automation, and offers a lot of functionality and power over a human-controlled browser.

It’s mainly used for production or integration environment testing/automatization, though it can also be used as a web scraper for research purposes.

How useful this article was :

Rating: 1 out of 5.

Published by 305kishan

Aspiring Data Scientist, Hardcore Gamer and Die Hard fan of Cristiano Ronaldo.

Leave a comment

Design a site like this with WordPress.com
Get started