Skip to content

updated the DOM element selector for the new freedom site - #2

Open
MikolajKawalec wants to merge 1 commit into
Booza1981:mainfrom
MikolajKawalec:main
Open

updated the DOM element selector for the new freedom site#2
MikolajKawalec wants to merge 1 commit into
Booza1981:mainfrom
MikolajKawalec:main

Conversation

@MikolajKawalec

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings February 24, 2026 10:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_TEXT to By.CSS_SELECTOR with class a.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.

Comment thread trigger_freedom_session.py
Comment thread trigger_freedom_session.py
Comment thread trigger_freedom_session.py

@Booza1981 Booza1981 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 existing WebDriverWait for #session_email still guards the credential entry on the new tab. Good reuse of existing flow.

Suggestions (non-blocking)

  1. Race on tab opentime.sleep(1) is a fixed wait. If the new tab takes >1s, window_handles may still list only one handle and [-1] would point at the original page, causing a NoSuchWindowException. Consider WebDriverWait(self.driver, 10).until(EC.number_of_windows_to_be(2)) before switching.
  2. 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.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants