python selenium截图
时间: 2023-08-28 09:04:15 浏览: 114
selenium for python
Python Selenium提供了多种截图方式来实现截图功能。其中一种方式是使用save_screenshot(file_name)方法,可以将当前窗口的截图保存为文件。代码示例如下:
```python
from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
driver.find_element_by_link_text('新闻').click()
sleep(3)
driver.save_screenshot('baidu1.png')
```
这段代码使用了Firefox浏览器,打开百度网站并点击了新闻链接,然后将整个窗口的截图保存为baidu1.png文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [selenium python 的四种截图方式](https://blog.csdn.net/weixin_45598506/article/details/107858423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [使用Python+Selenium的截图方法,这些必须要知道](https://blog.csdn.net/m0_52668874/article/details/125236365)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文