From 7fdd1386fa05f4ad8b42cf0053bc85aae1ad3a80 Mon Sep 17 00:00:00 2001 From: xietian Date: Wed, 18 Sep 2024 17:40:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- method/base_method.py | 17 ++++++++++++++++- method/image_res/close_window_btn2.png | Bin 0 -> 535 bytes 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 method/image_res/close_window_btn2.png diff --git a/method/base_method.py b/method/base_method.py index e2cf5e2..313852c 100644 --- a/method/base_method.py +++ b/method/base_method.py @@ -6,6 +6,7 @@ """ import os +import re import pylinuxauto from funnylog2 import logger from funnylog2.config import config as funnylog2_config @@ -42,7 +43,21 @@ class BaseMethod: def base_method_click_by_img(self, img_name): """通过图像识别点击""" - pylinuxauto.find_element_by_image(f"{config.IMAGE_RES}/{img_name}").click() + all_pngs = set() + img_name_tmp = img_name.split('.')[0] + + for tmp in os.listdir(config.IMAGE_RES): + if re.search(f'^{img_name_tmp}\d*.png', tmp): + all_pngs.add(tmp) + for img_tmp in all_pngs: + try: + pylinuxauto.find_element_by_image(f"{config.IMAGE_RES}/{img_tmp}").click() + break + except pylinuxauto.exceptions.TemplateElementNotFound: + pass + else: + raise pylinuxauto.exceptions.TemplateElementNotFound(img_name) + def base_method_double_click_by_img(self, img_name): """通过图像识别双击""" diff --git a/method/image_res/close_window_btn2.png b/method/image_res/close_window_btn2.png new file mode 100644 index 0000000000000000000000000000000000000000..09feff34b697771de055acad23f74cf75fc69c18 GIT binary patch literal 535 zcmV+y0_gpTP)(R7i={)XOgeK^zD0?{7Mit>{KrG@L~wZZ6{BD#Ro4y1BZR z@po7>@n;Yc@kj(0kBGYvA*npx@DS3N$#_{&t677l97*Mfc zdW}KRb`D~C#8BY5Zp7dqMhZy)00%Krt#VL^DK`JCQ~7_oJqrN6bH2%d8<>TbPB$s7 zS|Wg6GE1w>T7K#5Gws;cY;kGJ5lzzsBw6213Fvp+O;PxAQ+UK32zjTB;5P^6ZDK=! z5jMQyE(v)spi^rOI_~<6N8BSxk8Y=-V3dF%$92Vhe~|zVR{or>O&2~3A%+(aoG8D1 zSG0Pxej_+iW}{ZU;>e4F^_l<5(JDo?n*4MQ|aMf_KJsGxTUeUU0RMw zfr+CDR_j=rMyYrIA)c1ul5l2_v1aQnn@C~I^!qn+RN2kx(_~qar_Rn9^m7?j_ zY`qp%C8ly&j;iX5^nF_$jIaVXna!T3?>WM?S1*~Xr$ptVJ($L!>Ckj#A^?CRb*WYa Z@C{t2d}`fC5RCu;002ovPDHLkV1f*v@ooSB literal 0 HcmV?d00001 -- Gitee