Skip to content

Commit

Permalink
Merge pull request NaiboWang#233 from weiensong/master
Browse files Browse the repository at this point in the history
fix: catch exceptions with too large scope
感谢修复
  • Loading branch information
NaiboWang authored Nov 9, 2023
2 parents 025ebaf + ac634cf commit a90b679
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ExecuteStage/myChrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def find_element(self, by=By.ID, value=None, iframe=False):
# 在这个例子中,我们查找 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:
Expand Down Expand Up @@ -84,8 +84,8 @@ def find_elements(self, by=By.ID, value=None, iframe=False):
# 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:
Expand Down Expand Up @@ -128,8 +128,8 @@ def find_element(self, by=By.ID, value=None, iframe=False):
# 在这个例子中,我们查找 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:
Expand Down Expand Up @@ -164,8 +164,8 @@ def find_elements(self, by=By.ID, value=None, iframe=False):
# 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:
Expand Down

0 comments on commit a90b679

Please sign in to comment.