By支持的定位器元素包括:
CLASS_NAME = 'class name'
CSS_SELECTOR = 'css selector'
ID = 'id'
LINK_TEXT = 'link text'
NAME = 'name'
PARTIAL_LINK_TEXT = 'partial link text'
TAG_NAME = 'tag name'XPATH = 'xpath'
使用By前需要先import:from selenium.webdriver.common.by import By
1. find_element(By.ID,"kw")
2. find_element(By.NAME,"wd")
3. find_element(By.CLASS_NAME,"s_ipt")
4. find_element(By.TAG_NAME,"input")
5. find_element(By.LINK_TEXT,"新闻板块“)
6. find_element(By.PARTIAL_LINK_TEXT,"新”)
7. find_element(By.XPATH,"//*[@class='s_ipt']")
8. find_element(By.CSS_SELECTOR,“#kw”)