From 1ad2dc52bedaf44b55a2ad99c25aa01ac09a250d Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 28 Aug 2024 02:36:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/douyin/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tasks/douyin/__init__.py b/tasks/douyin/__init__.py index 3e8dd76..19e504a 100644 --- a/tasks/douyin/__init__.py +++ b/tasks/douyin/__init__.py @@ -2,9 +2,11 @@ from uiautomator2 import Device def click_search_icon(d: Device): - (d - .xpath('//*[@resource-id="com.ss.android.ugc.aweme:id/ybv"]/android.widget.Button[1]/android.widget.FrameLayout[1]') - .click()) + selector = d.xpath('//*[@resource-id="com.ss.android.ugc.aweme:id/ybv"]/android.widget.Button[' + '1]/android.widget.FrameLayout[1]') + if selector.exists: + selector.click() + def input_search_text(d: Device, text: str): (d