updated the DOM element selector for the new freedom site - #2
updated the DOM element selector for the new freedom site#2MikolajKawalec wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request updates the login automation to handle changes in the Freedom website's DOM structure. The site now opens login in a new browser tab rather than on the same page, requiring additional window handling logic.
Changes:
- Changed login button selector from
By.LINK_TEXTtoBy.CSS_SELECTORwith classa.nav_link-login - Added logic to switch to the new login tab that opens when clicking the login button
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Booza1981
left a comment
There was a problem hiding this comment.
Code Review
Verdict: Approve with minor suggestions — this is a targeted, sensible fix for a real DOM change on freedom.to (login now opens a new tab).
Looks good
- The selector change (
By.LINK_TEXT → By.CSS_SELECTOR a.nav_link-login) is the right move — the site's nav structure changed and a class-based selector is more stable than text matching. - Tab switching (
switch_to.window(window_handles[-1])) correctly targets the newest tab, and the existingWebDriverWaitfor#session_emailstill guards the credential entry on the new tab. Good reuse of existing flow.
Suggestions (non-blocking)
- Race on tab open —
time.sleep(1)is a fixed wait. If the new tab takes >1s,window_handlesmay still list only one handle and[-1]would point at the original page, causing aNoSuchWindowException. ConsiderWebDriverWait(self.driver, 10).until(EC.number_of_windows_to_be(2))before switching. - No fallback if the site reverts — if freedom.to ever returns to same-tab login, this PR would switch to a bogus handle. A check that the new tab actually contains the login form (
#session_email) before committing would make it robust. - Verify the post-login check — after switching tabs and logging in, the dashboard check (
blocklist-checklist) runs on the login tab. Confirm the dashboard loads there (not back on the original tab) before closing the PR; if it redirects back, a switch is needed post-login.
Note
This has been open since Feb 2026 and Copilot already reviewed it (COMMENTED). The change is low-risk and confined to the login function. Recommend merging once the author confirms the dashboard check passes on the switched tab.
No description provided.