driver.find_element_by_方法名(”value”)变为 driver.find_element(By.方法名, “value”)文章来源地址https://www.toymoban.com/news/detail-612026.html
from selenium.webdriver.common.by import By
# emg = driver.find_element_by_id("value") # 利用ID查找
# 改为:
emg = driver.find_element(By.ID, "value")
# emg = driver.find_element_by_class_name("value") # 利用类名查找
# 改为:
emg = driver.find_element(By.CLASS_NAME, "value")
# emg v= driver.find_element_by_name("value") # 利用name属性查找
# 改为:
emg = driver.find_element(By.NAME, "value")
# emg = driver.find_element_by_tag_name("value") # 利用标签名查找
# 改为:
emg = driver.find_element(By.TAG_NAME, "value")
# emg = driver.find_element_by_xpath("value") # 利用xpath查找
# 改为:
emg = driver.find_element(By.XPATH, "value")
# emg = driver.find_element_by_css_selector("value") # 利用CSS选择器查找
# 改为:
emg = driver.find_element(By.CSS_SELETOR, "value")
文章来源:https://www.toymoban.com/news/detail-612026.html
到了这里,关于selenium定位元素报错:AttributeError: ‘WebDriver‘ object has no attribute ‘find_element_by_xpath‘问题解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!