Get started with Selenium

Posted by Bruce Liu on May 23, 2020 , updated on May 24, 2020

🏷️ Tags: selenium , webdriver , python , chrome , wsl


  • A browser is a must. One of Chrome, Firefox, Edge, Safari, Opera, IE, etc.

  • Driver for your browser.

Further more, there are some nice tools such as webdriver-manager, chromedriver-autoinstaller and geckodriver-autoinstaller to check, download and install a suitable driver from python automatically.

Although WSL doesn’t support GUI directly, there are still ways to use WebDrivers/Selenium. Here is a proven method, In short, just place ChromeDriver in some system directory in windows for example C:\Windows\System32, and remove .exe extension. After that, your can use from wsl directly.

Common usages

from selenium import webdriver
from selenium.webdriver.common.keys import Keys #provide special keys in the keywords
from import ChromeDriverManager

#check ChromeDriver and open a new Chrome browser
browser = webdriver.Chrome(ChromeDriverManager().install())

#load Yahoo homepage
assert 'Yahoo' in browser.title

#find the search box
elem = browser.find_element_by_name('p')

#input 'seleniumhq' and type 'ENTER'
elem.send_keys('seleniumhq' + Keys.RETURN)

#close the browser


selenium.webdriver.ChromeOptions() is equivalent to

#open a new ChromeOptions object
options = webdriver.ChromeOptions()

#add agruments

#open a new Chrome browser
driver = Chrome(options=options)

Further more arguments for Chrome, go after here.


There is a fantastic blog to guide the usage of XPath. Click here

And you can test a XPath in Chrome Console. F12 –> Console –> Type your XPath like $x(“.//*[@id='id']”) –> ENTER.


  • submit the daily report to server, see source code.

  • require cookies from Google Earth Engine, see source code.


Python tools

Share on:

« PREVIOUS: FAQ for Docker in Chinese
NEXT: Difference between list.sort() and sorted() in Python »