[Python] ERROR : 'WebDriver' object has no attribute 'find_element_by_xpath'

Denver·2022년 10월 24일
0

ERROR

목록 보기
1/6
post-thumbnail

Python : 3.7.9
Selenium : 4.5.0

Error
    appname = driver.find_element_by_xpath('//*[@id="__next"]/div/h1').text
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
해결 방법
from selenium.webdriver.common.by import By
appname = driver.find_element(By.XPATH, '//*[@id="__next"]/div/h1').text

By.ID
By.NAME
By.XPATH
By.LINK_TEXT
By.PARTIAL_LINK_TEXT
By.TAG_NAME
By.CLASS_NAME
By.CSS_SELECTOR

https://www.selenium.dev/documentation/webdriver/getting_started/upgrade_to_selenium_4/

profile
까먹었을 미래의 나를 위해

0개의 댓글