-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.py
More file actions
32 lines (29 loc) · 825 Bytes
/
function.py
File metadata and controls
32 lines (29 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#coding:utf-8
#@time : 2017/9/29 20:40
#@Author : mengzh
#@file :{name}.py
# @Site :
# @File : function.py
# @Software: PyCharm Community Edition
from selenium import webdriver
import os
#截图函数
def insert_img(driver, file_name):
base_dir = os.path.dirname(os.path.dirname(__file__))
#print(base_dir)
base_dir = str(base_dir)
#print(base_dir)
base_dir = base_dir.replace('\\','/')
#print(base_dir)
base = base_dir.split('/mail')[0]
#print(base)
file_path = base + '/mail/report/image/' + file_name
driver.get_screenshot_as_file(file_path)
'''
17 #用于验证该脚本是否有效
18 if __name__ == '__main__':
19 driver = webdriver.Chrome()
20 driver.get('http://www.baidu.com')
21 insert_img(driver, 'baidu.jpg')
22 driver.quit()
23 '''