Browse Source

fix: catch exceptions with too large scope

pull/233/head
touer 10 months ago
committed by GitHub
parent
commit
ac634cfafc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 8 deletions
  1. +8
    -8
      ExecuteStage/myChrome.py

+ 8
- 8
ExecuteStage/myChrome.py View File

@ -48,8 +48,8 @@ class MyChrome(webdriver.Chrome):
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
element = super().find_element(by=by, value=value)
find_element = True
except:
print("No such element found in the iframe")
except NoSuchElementException as e:
print(f"No such element found in the iframe: {str(e)}")
# 完成操作后切回主文档
# super().switch_to.default_content()
if find_element:
@ -84,8 +84,8 @@ class MyChrome(webdriver.Chrome):
# super().switch_to.default_content()
if find_element:
return elements
except:
print("No such element found in the iframe")
except NoSuchElementException as e:
print(f"No such element found in the iframe: {str(e)}")
if not find_element:
raise NoSuchElementException
else:
@ -128,8 +128,8 @@ if sys.platform != "darwin":
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
element = super().find_element(by=by, value=value)
find_element = True
except:
print("No such element found in the iframe")
except NoSuchElementException as e:
print(f"No such element found in the iframe: {str(e)}")
# 完成操作后切回主文档
# super().switch_to.default_content()
if find_element:
@ -164,8 +164,8 @@ if sys.platform != "darwin":
# super().switch_to.default_content()
if find_element:
return elements
except:
print("No such element found in the iframe")
except NoSuchElementException as e:
print(f"No such element found in the iframe: {str(e)}")
if not find_element:
raise NoSuchElementException
else:

Loading…
Cancel
Save