Skip to main content

Selenium plugin library

Project description

UI-Pic-Rec

本库目前支持的相似性算法

1.采用SSIM算法(结构相似性算法):generate_diff_pic_between_ssim

2.采用余弦方法:generate_diff_pic_between_vector

注意:后续会不断的补充相应的算法,丰富比较的结果

安装

pip install -r requirements.txt

pip install pic-diff-recognizer

最佳实践

from selenium.webdriver import Chrome,ActionChains
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os
import time
import logging
from pathlib import Path
from findHander import FindHander
from picHander import *

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s') 
logger = logging.getLogger("Example")
chrome_driver='/Users/lijishuang/Downloads/chromedriver' #需要更改成本机目录的地址
options = webdriver.ChromeOptions()
options.add_argument('--headless')
dr = webdriver.Chrome(executable_path=chrome_driver,chrome_options=options)

def function_pic(dr,path_self):
    pt = FindHander(dr.save_screenshot)

    dr.set_window_size(1920, 1080)
    origin_url = 'https://www.baidu.com/'
    dr.get(origin_url)
    dr.implicitly_wait(10)

    pt.get_pic_traverse(path_self)

    elem = dr.find_element_by_name("wd")
    elem.send_keys('今日头条'+ Keys.RETURN)
    time.sleep(5)
    # 截
    pt.get_pic_traverse(path_self)
"""
path_self:定义保存截图的目录,使用 --from pathlib import Path-- 定义路径
使用get_pic_traverse进行需要保存截图的地方使用
"""
path_self_org = Path(os.getcwd()).joinpath('org')
path_self_sap = Path(os.getcwd()).joinpath('sap')
function_pic(dr,path_self_org)
function_pic(dr,path_self_sap)

logger.info(f"Staring ...")
compare_res,file_name_org = compare_result_pic_data()
logger.info(file_name_org)
logger.info(f"Starting SSIM Progress ...")

result_score = PicHander(compare_res).generate_diff_pic_between_ssim(file_name_org)

print(result_score)


logger.info(f"Staring ...")
compare_res,file_name_org = compare_result_pic_data()
logger.info(file_name_org)
logger.info(f"Starting Vector Progress ...")

result_score = PicHander(compare_res).generate_diff_pic_between_vector(file_name_org)

print(result_score)
执行后会在所调用的脚本目录下生成三个文件夹:
diff:依据org和sap目录下的图片的名字生成目录,保存每一次比较的记录之间的不同的图片,会在图片中进行标记;
org:存储待比较的图片信息(第一次产生的信息);
sap:存储待比较的图片信息(第二次产生的信息);

# 联系我

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

UiComparePicRec-1.1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

UiComparePicRec-1.1.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

Details for the file UiComparePicRec-1.1.0.tar.gz.

File metadata

  • Download URL: UiComparePicRec-1.1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for UiComparePicRec-1.1.0.tar.gz
Algorithm Hash digest
SHA256 cacb0997524ff480625a05540f7abc5aceb832ec44cc0cd68ba410670a1b8f8a
MD5 c843a4e0887eb29d1cd309a3ec44e050
BLAKE2b-256 e77f20a1791a7cc902e0a2c44e48da9a0a5961dc14561eb35bd69a7d1718824d

See more details on using hashes here.

File details

Details for the file UiComparePicRec-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: UiComparePicRec-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for UiComparePicRec-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b78f757f6e955698ef6c4b43597d2f7bcb006231a9be89528e5600b31340bab
MD5 f2a44664b4883b28af85e15e85b992c0
BLAKE2b-256 72e08c28436966f89f8b2c5db3db58c6e7750f5ee54f9d5d20906105f8eb0978

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page