Introduction

selenium

Installation

Create python virtual environment and install selenium via pip:

conda create -n selenium
conda activate selenium
pip install selenium

Download the Chrome Driver, unzip, and move the chromedirver to bin of virtual environment.

# check your path via `conda env list`
mv chromedirver /opt/miniconda3/envs/selenium/bin

Check in python:

from selenium import webdriver

driver = webdriver.Chrome()

You should see a website opened by Chrome now.

Quick Start

Reference

  • open and close website
import time
from selenium import webdriver

# start a session in Chrome
driver = webdriver.Chrome()
# be navigated to the website `http://www.bing.com`
driver.get("http://www.bing.com")
time.sleep(10)
driver.quit()
  • click and send keys TBC

  • wait TBC