1. 程式人生 > >Python 利用Webdriver進行UI測試頁面截圖

Python 利用Webdriver進行UI測試頁面截圖

#!/user/bin/python3
# coding:utf-8


import time

def screenshot(self):
    current_time = time.strftime("IMG_%Y%m%d%H%M%S", time.localtime(time.time()))
    print(current_time)
    pic_path = 'C:/Users/foresee/.PyCharm2017.3/Test_UI/image/' + '/' + current_time + '.png'
    print('儲存截圖路徑為:', pic_path)
    self.driver.get_screenshot_as_file(pic_path)