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

发布一下 0 0

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 sleepfrom selenium import webdriverfrom 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)



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

版权声明:内容来源于互联网和用户投稿 如有侵权请联系删除

本文地址:http://0561fc.cn/196239.html