DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
from selenium.webdriver.common.by import By
driver = webdriver.Chrome("chromedriver.exe")
# driver.find_element_by_name("NAME")
driver.find_element(By.NAME, "NAME")
# driver.find_element_by_class_name("CLASS_NAME")
driver.find_element(By.CLASS_NAME, "CLASS_NAME")
# driver.find_element_by_id("ID")
driver.find_element(By.ID, "ID")
# driver.find_element_by_xpath("XPATH")
driver.find_element(By.XPATH, "XPATH")
element = self.driver.find_element_by_link_text('车票')
DeprecationWarning: find_element_by_* commands are deprecated. Please use find_element() instead
class By(object):
"""
Set of supported locator strategies.
"""
ID = "id"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
NAME = "name"
TAG_NAME = "tag name"
CLASS_NAME = "class name"
CSS_SELECTOR = "css selector"
element = self.driver.find_element(By.LINK_TEXT,'车票')
标签:commands,name,Please,driver,element,find,NAME From: https://www.cnblogs.com/xkdn/p/18400883