Skip to content

Instantly share code, notes, and snippets.

@t0mst0ne
Created September 7, 2018 01:25
Show Gist options
  • Save t0mst0ne/f4f2d4f8bad49f585c59e5ac5353b5f7 to your computer and use it in GitHub Desktop.
Save t0mst0ne/f4f2d4f8bad49f585c59e5ac5353b5f7 to your computer and use it in GitHub Desktop.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
service = webdriver.chrome.service.Service('/usr/bin/chromedriver')
service.start()
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options = options.to_capabilities()
driver = webdriver.Remote(service.service_url, options)
driver.get('https://google.com')
# Locate the search box element
search_box = driver.find_element_by_name('q')
import time
time.sleep(5)
#type in our search query into the search box
search_box.send_keys('seleniumhq' + Keys.RETURN)
time.sleep(1)
print(driver.title)
driver.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment