zoukankan      html  css  js  c++  java
  • selenium学习对当前浏览器窗口截屏

    方法:get_screenshot_as_file(filename)

    # coding=UTF-8
    #16.对当前浏览器窗口截屏
    import sys
    reload(sys)
    sys.setdefaultencoding('utf8')
    from selenium import webdriver
    import unittest
    import time
    
    class Case16(unittest.TestCase):
    
        def setUp(self):
            self.driver = webdriver.Chrome()
    
        def test_captureScreenInCurrentWindow(self):
            url = "https://www.sogou.com"
            self.driver.get(url)
            try:
                result = self.driver.get_screenshot_as_file(r"C:\Users\xxx\Desktop\screenPicture.png")
                print result
            except IOError,e:
                print e
    
        def tearDown(self):
            self.driver.quit()
    
    if __name__ == '__main__':
        unittest.main()

    注:Python的 IOErro错误主要是指要打开的文件不存在的错误提示

  • 相关阅读:
    Segment Routing之IPv6 SR概述
    ping6 connect: Invalid argument
    glance image-list
    SRv6技术研究和组网设计
    physical_interface_mappings
    bond
    srv6 tools---SRext
    srv6
    8月18号
    8月17号
  • 原文地址:https://www.cnblogs.com/erchun/p/11778167.html
Copyright © 2011-2022 走看看