from selenium import webdriver
from time import sleep
from selenium.webdriver.common.by import By
# 通过ID来定位
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.get('http://www.baidu.com')
# sleep(3)
# driver.find_element(By.ID, 'kw').send_keys("极客时间")
# driver.find_element(By.ID, "su").click()
#
# sleep(3)
# driver.quit()
# 通过NAME来定位
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.get('http://www.baidu.com')
# sleep(3)
# driver.find_element(By.NAME, 'wd').send_keys("极客时间")
# driver.find_element(By.ID, 'su').click()
#
# sleep(3)
# driver.quit()
# # 通过xpath来定位
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.get('http://www.baidu.com')
# sleep(1)
# driver.find_element(By.XPATH, '//*[@id="kw"]').send_keys("极客时间")
# driver.find_element(By.ID, 'su').click()
#
# sleep(3)
# driver.quit()
# 通过CSS选择器来定位
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.get('http://www.baidu.com')
# sleep(1)
# driver.find_element(By.CSS_SELECTOR, '#kw').send_keys("极客时间")
# driver.find_element(By.ID, 'su').click()
#
# sleep(3)
# driver.quit()