Selenium---Python3---weddriver错误截图
2021-02-12 23:20
标签:sleep color test cep pychar win32 send www bsp 通过函数get_screenshot_as_file()来捕获错误截图,详细看下面举例: Selenium---Python3---weddriver错误截图 标签:sleep color test cep pychar win32 send www bsp 原文地址:https://www.cnblogs.com/aaron456-rgv/p/12729072.html#coding = utf-8
from selenium import webdriver
import time
#Selenium cookie处理
#D:\chromedriver_win32\chromedriver.exe
#webdriver 可以帮助我们读取,添加,删除cookie信息。
class browser_1(object):
def __init__(self):
self.browser = webdriver.Chrome(‘D:\chromedriver_win32\chromedriver.exe‘)
def browser_1(self):
self.browser.get(‘https://www.baidu.com/‘)
try:
self.browser.find_element_by_id(‘kwsss‘).send_keys(‘selenium‘)
self.browser.find_element_by_id(‘su‘).click()
except:
self.browser.get_screenshot_as_file(r"D:\PycharmProjects1\error_test\error_png.png")
time.sleep(3)
self.browser.quit()
if __name__ == "__main__":
a = browser_1()
a.browser_1()
文章标题:Selenium---Python3---weddriver错误截图
文章链接:http://soscw.com/index.php/essay/54665.html