Python-web自动化之三种自动截图

20221225星期日:


截图方式一:driver.get_screenshot_as_file('./get_screenshot_as_file-01.png')

截图方式二:driver.save_screenshot('./save_screenshot-01.png')

截图方式三:img_lable.screenshot('./screenshot-01.png')


"""
@Project : For_Python_Pro
@File : 截图_get_screenshot_as_file.py
@Author : Administrator
@Time : 2022/12/25 09:24
@Product : PyCharm
"""

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By


# 1,不显示浏览器顶部的正在受自动测试软件的控制:
driver_path = "./chromedriver.exe"
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["enable-automation"])
driver = webdriver.Chrome(options=options,executable_path=driver_path)
driver.get("http://www.hao123.com/")
driver.maximize_window()


sleep(3)
# 截图方式一:
driver.get_screenshot_as_file('./get_screenshot_as_file-01.png')
sleep(3)
# 截图方式二:
driver.save_screenshot('./save_screenshot-01.png')
sleep(3)
# 截图方式三:
# 使用此方法,可以进行存储弹框的图片:
# 定位验证码框框:
img_lable = driver.find_element(By.CLASS_NAME,'zllogo')
img_lable.screenshot('./screenshot-01.png')
sleep(10)



展开阅读全文

页面更新:2024-05-09

标签:截图   框框   星期日   浏览器   方式   测试   方法   图片   软件

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号

Top