当前位置:网站首页>selenium将元素保存为图片

selenium将元素保存为图片

2022-06-26 15:16: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)

参考
https://stackoverflow.com/questions/17361742/download-image-with-selenium-python

原网站

版权声明
本文为[nongcunqq]所创,转载请带上原文链接,感谢
https://blog.csdn.net/nongcunqq/article/details/125387745