import selenium code example

Example 1: install selenium python

# for Windows
pip install selenium

# for Linux/Max
pip3 install selenium
# or
sudo -H pip3 install selenium

Example 2: selenium import options

from selenium.webdriver.chrome.options import Options

Example 3: how to start off a selenuim python

import selenium.webdriver as webdriver
driver = webdriver.Chrome()

Example 4: selenium getting started

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

Tags:

Misc Example