-
Notifications
You must be signed in to change notification settings - Fork 0
/
test2.py
17 lines (16 loc) · 858 Bytes
/
test2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.expected_conditions import presence_of_element_located
from selenium.webdriver.firefox.options import Options
#other imports here
options = Options()
options.headless = True
#This example requires Selenium WebDriver 3.13 or newer
with webdriver.Firefox(executable_path=r'C:\WebDrvTools\bin\geckodriver.exe', options=options) as driver:
wait = WebDriverWait(driver, 10)
driver.get("https://google.com/ncr")
driver.find_element(By.NAME, "q").send_keys("cheese" + Keys.RETURN)
first_result = wait.until(presence_of_element_located((By.CSS_SELECTOR, "h3>div")))
print(first_result.get_attribute("textContent"))