From 889eb2074641bee74a62d53e936f9e4d65523afd Mon Sep 17 00:00:00 2001 From: g1879 Date: Fri, 5 Feb 2021 21:01:10 +0800 Subject: [PATCH] =?UTF-8?q?click()=E6=94=AF=E6=8C=81=E5=81=8F=E7=A7=BB?= =?UTF-8?q?=E7=82=B9=E5=87=BB=EF=BC=8C=E6=9C=AA=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DrissionPage/driver_element.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DrissionPage/driver_element.py b/DrissionPage/driver_element.py index 06fb5db..83b4001 100644 --- a/DrissionPage/driver_element.py +++ b/DrissionPage/driver_element.py @@ -324,7 +324,7 @@ class DriverElement(DrissionElement): return None if r == 'none' else r - def click(self, by_js=None) -> bool: + def click(self, by_js: bool = None, x: int = None, y: int = None) -> bool: """点击元素 \n 尝试点击10次,若都失败就改用js点击 \n :param by_js: 是否用js点击,为True时直接用js点击,为False时重试失败也不会改用js @@ -532,12 +532,14 @@ class DriverElement(DrissionElement): if(nth>1){path = '/' + tag + '[' + nth + ']' + path;} else{path = '/' + tag + path;}''' txt5 = '''return path;''' + elif mode == 'css': txt1 = '' # txt2 = '''return '#' + el.id + path;''' txt3 = '' txt4 = '''path = '>' + ":nth-child(" + nth + ")" + path;''' txt5 = '''return path.substr(1);''' + else: raise ValueError(f"Argument mode can only be 'xpath' or 'css', not '{mode}'.")