文章目录
- 使用 save_screenshot() 函数在 Python 中使用 selenium 捕获屏幕截图
- 使用 get_screenshot_as_file() 函数在 Python 中使用 selenium 捕获屏幕截图
- 使用 Screenshot-Selenium 包在 Python 中使用 selenium 捕获屏幕截图
- 总结
我们可以使用 Selenium 在自动化 Web 浏览器上使用 Python 脚本执行任务。 我们可以使用不同的方法将浏览器的屏幕捕获为屏幕截图。
本篇文章将介绍如何在 Python 中使用 selenium 捕获自动浏览器的屏幕截图。
使用 save_screenshot() 函数在 Python 中使用 selenium 捕获屏幕截图
selenium 包提供了 save_screenshot()
函数来截取在自动浏览器中打开的网页的屏幕截图。
我们可以在函数中指定屏幕截图的文件名(PNG 格式)和路径。 该函数与 webdriver 对象一起使用。
请参阅下面的代码。
from se