add: handle errors for no user element

This commit is contained in:
Jarrian
2023-09-09 17:43:07 +08:00
parent efb0c65c39
commit 07ece4e29a
2 changed files with 9 additions and 3 deletions

View File

@@ -6,9 +6,12 @@ class Tweet:
def __init__(self, card: Chrome) -> None:
self.card = card
self.user = card.find_element(
"xpath", './/div[@data-testid="User-Name"]//span'
).text
try:
self.user = card.find_element(
"xpath", './/div[@data-testid="User-Name"]//span'
).text
except NoSuchElementException:
return
try:
self.handle = card.find_element(