Skip to content

fix: update social_media.py to Selenium 4 API and add missing deps#6

Open
cluster2600 wants to merge 1 commit intomalwaredojo:mainfrom
cluster2600:fix/selenium4-api-and-missing-deps
Open

fix: update social_media.py to Selenium 4 API and add missing deps#6
cluster2600 wants to merge 1 commit intomalwaredojo:mainfrom
cluster2600:fix/selenium4-api-and-missing-deps

Conversation

@cluster2600
Copy link
Contributor

What

  • Update loki/core/social_media.py to use the Selenium 4 find_element(By.*, ...) API
  • Add selenium and webdriver-manager to requirements.txt (they were missing)

Why

Selenium 4 removed the legacy shorthand methods like find_element_by_name() and find_element_by_css_selector() that were deprecated in Selenium 3. Any user running pip install -r requirements.txt and then using the -soc / --social-create flag will encounter two errors:

  1. ImportErrorselenium and webdriver-manager are imported in social_media.py but not listed in requirements.txt
  2. AttributeError: 'WebDriver' object has no attribute 'find_element_by_name' – Selenium 4 removed these legacy methods

How

loki/core/social_media.py:

  • Added from selenium.webdriver.common.by import By
  • Replaced all find_element_by_name(x)find_element(By.NAME, x)
  • Replaced find_element_by_css_selector(x)find_element(By.CSS_SELECTOR, x)

requirements.txt:

  • Added selenium>=4.0.0
  • Added webdriver-manager>=4.0.0

Testing

  • Verified the updated syntax against the Selenium 4 migration guide
  • All find_element_by_* patterns replaced with the current find_element(By.*, ...) API

Checklist

  • Fixes AttributeError crash on Selenium 4
  • Fixes missing dependency declaration in requirements.txt
  • No logic changes — only API migration for forward compatibility
  • Consistent with Selenium 4 official migration guide

Selenium 4 removed the legacy shorthand methods such as
find_element_by_name(), find_element_by_css_selector(), etc.
These were deprecated in Selenium 3 and raise AttributeError in
Selenium 4+.

Changes:
- Import selenium.webdriver.common.by.By
- Replace all find_element_by_*() calls with find_element(By.*, ...)
  syntax supported by Selenium 4
- Add selenium>=4.0.0 and webdriver-manager>=4.0.0 to requirements.txt
  (both were used in social_media.py but not declared as dependencies,
  causing ImportError for users who install only requirements.txt)

This fixes a crash for any user running the -soc / --social-create flag
on Selenium 4, which is the current release line.
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.

1 participant