当前位置:网站首页>Selenium saves elements as pictures

Selenium saves elements as pictures

2022-06-26 15:41:00 nongcunqq

driver = webdriver.Chrome( executable_path=CHROME_DRIVER_PATH)
def login():
    driver.get(url_index)
    wait = WebDriverWait(driver, 60)
    wait.until(EC.visibility_of_element_located((By.XPATH, '//*[@id="Form1"]/div[3]/table/tbody/tr[3]/td[1]/img')))
    captcha_elm = driver.find_element(by=By.XPATH, value='//*[@id="Form1"]/div[3]/table/tbody/tr[3]/td[1]/img')

    png_path = '1.png'
    with open(png_path, 'wb') as file:
        file.write(captcha_elm.screenshot_as_png)

Reference resources
https://stackoverflow.com/questions/17361742/download-image-with-selenium-python

原网站

版权声明
本文为[nongcunqq]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261515515052.html