From bb0f83b696da711b4bf409ef64b7e4b4ae5ab66a Mon Sep 17 00:00:00 2001 From: Stam He Date: Fri, 19 Jul 2024 21:54:36 -0500 Subject: [PATCH] fix get_eles exception --- .gitignore | 2 ++ DrissionPage/_functions/elements.py | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 11614af..662124d 100644 --- a/.gitignore +++ b/.gitignore @@ -113,3 +113,5 @@ dmypy.json # Pyre type checker .pyre/ + +.idea/ diff --git a/DrissionPage/_functions/elements.py b/DrissionPage/_functions/elements.py index cccb8da..cc4052c 100644 --- a/DrissionPage/_functions/elements.py +++ b/DrissionPage/_functions/elements.py @@ -393,11 +393,16 @@ def get_eles(locators, owner, any_one=False, first_ele=True, timeout=10): for loc in locators: if res[loc] is not False: continue - ele = owner.ele(loc, timeout=0) if first_ele else owner.eles(loc, timeout=0) - if ele: - res[loc] = ele - if any_one: - return res + + try: + ele = owner.ele(loc, timeout=0) if first_ele else owner.eles(loc, timeout=0) + if ele: + res[loc] = ele + if any_one: + return res + except Exception as e: + pass + if False not in res.values(): break return res