Skip to content

Commit

Permalink
add exceptions and refactor locating avatar link
Browse files Browse the repository at this point in the history
  • Loading branch information
isaac-chung committed Aug 31, 2024
1 parent 8e58d85 commit 53b7ccb
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions give_kudos.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@ def email_login(self):
self.page.goto(os.path.join(BASE_URL, 'login'))
try:
self.page.get_by_role("button", name="Reject").click(timeout=5000)
print("Rejecting cookies.")
except:
pass

try:
self.page.get_by_placeholder("Your Email").fill(self.EMAIL, timeout=5000)
print("Using placeholder")
except:
except Exception as e:
self.page.locator("input#email").fill(self.EMAIL, timeout=5000)
print("Using CSS selector (using ID)")
print("Using CSS selector (using ID)", e)

try:
self.page.get_by_placeholder("Password").fill(self.PASSWORD, timeout=5000)
print("Using placeholder")
except:
except Exception as e:
self.page.locator("input#password").fill(self.PASSWORD, timeout=5000)
print("Using CSS selector (using ID)")
print("Using CSS selector (using ID)", e)

self.page.get_by_role("button", name='Log In').click()
print("---Logged in!!---")
Expand Down Expand Up @@ -83,9 +84,15 @@ def _get_page_and_own_profile(self):

try:
self.own_profile_id = self.page.locator(".user-menu > a").get_attribute('href').split("/athletes/")[1]
print("id", self.own_profile_id)
except:
print("can't find own profile ID")
try:
full_link = self.page.locator("#athlete-profile").get_by_test_id("avatar-wrapper").get_attribute('href')
self.own_profile_id = full_link.split("/athletes/")[1]
print("Found top right avatar")
except Exception as e:
print("can't find own profile ID", e)

print("id", self.own_profile_id)

def locate_kudos_buttons_and_maybe_give_kudos(self, web_feed_entry_locator) -> int:
"""
Expand Down

0 comments on commit 53b7ccb

Please sign in to comment.