亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium實(shí)現(xiàn)chrome分屏截圖的合并
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/5/10 13:09:57 ] 推薦標(biāo)簽:功能測試 軟件測試工具

  selenium的截圖功能在chrome下無法實(shí)現(xiàn),但是可以操作滾動(dòng)條來一屏一屏的截圖,然后再合并成一張圖,解決方案如下:
def test_capture(url, w_pix,h_pix):
try:
self.driver.set_window_size(w_pix,h_pix)
self.driver.get(url)
self.driver.implicitly_wait(5)
i = 0
img_list = []
while i<30:
js="var q=document.body.scrollTop="+ str(i*wap_pixs[pix][1])+";"
self.driver.execute_script(js)
time.sleep(1)
js1 = "return document.body.scrollHeight-document.body.scrollTop"
s= self.driver.execute_script(js1)
if h_pix >= s:
break
else:
self.driver.save_screenshot(str(i)+'.png')
img_list.append(str(i)+'.png')
i += 1
image_merge(img_list)
except:
print 'error'
from PIL import Image
def image_merge(images, output_dir='', output_name='merge.jpg', restriction_max_width=None, restriction_max_height=None):
"""垂直合并多張圖片
images - 要合并的圖片路徑列表
ouput_dir - 輸出路徑
output_name - 輸出文件名
restriction_max_width - 限制合并后的圖片大寬度,如果超過將等比縮小
restriction_max_height - 限制合并后的圖片大高度,如果超過將等比縮小
"""
def image_resize(img, size=(1500, 1100)):
"""調(diào)整圖片大小
"""
try:
if img.mode not in ('L', 'RGB'):
img = img.convert('RGB')
img = img.resize(size)
except Exception, e:
pass
return img
max_width = 0
total_height = 0
# 計(jì)算合成后圖片的寬度(以寬的為準(zhǔn))和高度
for img_path in images:
if os.path.exists(img_path):
img = Image.open(img_path)
width, height = img.size
if width > max_width:
max_width = width
total_height += height
# 產(chǎn)生一張空白圖
new_img = Image.new('RGB', (max_width, total_height), 255)
# 合并
x = y = 0
for img_path in images:
if os.path.exists(img_path):
img = Image.open(img_path)
width, height = img.size
new_img.paste(img, (x, y))
y += height
if restriction_max_width and max_width >= restriction_max_width:
# 如果寬帶超過限制
# 等比例縮小
ratio = restriction_max_height / float(max_width)
max_width = restriction_max_width
total_height = int(total_height * ratio)
new_img = image_resize(new_img, size=(max_width, total_height))
if restriction_max_height and total_height >= restriction_max_height:
# 如果高度超過限制
# 等比例縮小
ratio = restriction_max_height / float(total_height)
max_width = int(max_width * ratio)
total_height = restriction_max_height
new_img = image_resize(new_img, size=(max_width, total_height))
if not os.path.exists(output_dir):
os.makedirs(output_dir)
save_path = '%s/%s' % (output_dir, output_name)
new_img.save(save_path)
for img_path in images:
os.remove(img_path)
return save_path
  大致這么個(gè)思路

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 天天av天天翘天天综合网 | 成年视频国产免费观看 | 人人艹人人艹 | 一级毛片免费观看不卡视频 | 日韩黄色影片 | 亚洲一级视频在线观看 | 精品国产综合成人亚洲区 | 最近2019免费中文字幕8 | 国产精品午夜波多野结衣性色 | 一一本大道香蕉大 | 中文字幕日韩精品一区口 | 在线观看国产一区二区三区99 | 日本大臿亚洲香蕉大片 | 亚洲视频欧美 | 福利片在线播放 | 亚洲一区二区三区网站 | 最新日韩精品 | 黄色三级网 | 小明台湾www永久视频 | 日本黄色三级网站 | 日批视频在线播放 | 狠狠色噜噜狠狠狠合久 | 黄色网址免费观看视频 | 特级毛片s级全部免费 | 色久在线 | 特级全黄一级毛片视频 | 污污香蕉视频 | 手机在线国产精品 | 99在线公开免费视频 | 亚洲成a人片在线观看中文!!! | 国产 第1页| 五月天婷婷在线播放 | 欧美日韩亚洲人人夜夜澡 | 这里只有精品99re在线 | 最近中文字幕视频国语中文字幕 | 色黄大色黄女片免费看软件 | 全色网站 | 亚洲第一区香蕉_国产a | 天天摸天天摸天天躁 | 国产精品自产拍在线观看 | 日本大片免费一级 |