Selenium Hello World with Python

By xngo on February 20, 2019


Selenium is a tool that take control over the browsers and simulate web surfing activities. Therefore, it is able to replicate any action typically undertaken by a user, such as clicking, typing and retrieving data from web pages. I will show you how to setup and run Selenium using Python.


# Install the python package manager, pip.
    apt-get install python-pip
# Install Python bindings for Selenium.
    pip install selenium
# Download Webdriver for Chrome from 
#   <>. 

Run Selenium

  1. Close all instances of your Chrome browser.
  2. Run ./chromedriver on 1 terminal and then run the Python code below from another terminal.
# Description: The Python code below will search selenium in Google.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome()
search_box = driver.find_element_by_name('q')  # Find search input box.
search_box.send_keys('selenium')               # Type in selenium.
search_box.send_keys(Keys.RETURN)              # Press ENTER.
# Close.

Here is a video showing the code above in action.

Video showing Selenium in action

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.