다다

2023. 11. 6. 13:49카테고리 없음

반응형

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException

# 웹 드라이버 초기화
driver = webdriver.Chrome("chromedriver.exe")
driver.get("https://example.com")

try:
    # 원하는 XPath 클릭
    element = driver.find_element_by_xpath("your_xpath_here")
    element.click()
except NoSuchElementException:
    # 해당 XPath가 없을 경우 예외 처리
    pass

# 웹 드라이버 종료
driver.quit()

반응형