From fc9895e364e6ebc7a50c7f1c5b824cceb795b739 Mon Sep 17 00:00:00 2001 From: Maxime Grenu Date: Wed, 18 Feb 2026 20:18:17 +0100 Subject: [PATCH] fix: update social_media.py to Selenium 4 API and add missing deps 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. --- loki/core/social_media.py | 22 ++++++++++++---------- requirements.txt | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/loki/core/social_media.py b/loki/core/social_media.py index 2349b66..e1cbc7b 100644 --- a/loki/core/social_media.py +++ b/loki/core/social_media.py @@ -1,6 +1,7 @@ #!/usr/bin/python3 from selenium import webdriver from selenium.webdriver.chrome.service import Service +from selenium.webdriver.common.by import By from webdriver_manager.chrome import ChromeDriverManager from core.colours import * import time @@ -15,16 +16,17 @@ def create_social_accounts(person_data): driver.get("https://www.facebook.com/r.php") time.sleep(2) # Wait for page load - # Fill in form (example fields; adjust selectors as needed) - driver.find_element_by_name("firstname").send_keys(person_data['name'].split()[0]) - driver.find_element_by_name("lastname").send_keys(person_data['name'].split()[-1]) - driver.find_element_by_name("reg_email__").send_keys(person_data['email']) - driver.find_element_by_name("reg_passwd__").send_keys("SecurePass123!") - driver.find_element_by_name("birthday_day").send_keys(person_data['birthday'].split('/')[0]) - driver.find_element_by_name("birthday_month").send_keys(person_data['birthday'].split('/')[1]) - driver.find_element_by_name("birthday_year").send_keys(person_data['birthday'].split('/')[2]) - driver.find_element_by_css_selector(f"input[value='{person_data['gender'].lower()[0]}']").click() - driver.find_element_by_name("websubmit").click() + # Fill in form fields using the Selenium 4 API (By.NAME instead of + # the deprecated find_element_by_name shorthand removed in Selenium 4) + driver.find_element(By.NAME, "firstname").send_keys(person_data['name'].split()[0]) + driver.find_element(By.NAME, "lastname").send_keys(person_data['name'].split()[-1]) + driver.find_element(By.NAME, "reg_email__").send_keys(person_data['email']) + driver.find_element(By.NAME, "reg_passwd__").send_keys("SecurePass123!") + driver.find_element(By.NAME, "birthday_day").send_keys(person_data['birthday'].split('/')[0]) + driver.find_element(By.NAME, "birthday_month").send_keys(person_data['birthday'].split('/')[1]) + driver.find_element(By.NAME, "birthday_year").send_keys(person_data['birthday'].split('/')[2]) + driver.find_element(By.CSS_SELECTOR, f"input[value='{person_data['gender'].lower()[0]}']").click() + driver.find_element(By.NAME, "websubmit").click() time.sleep(5) # Wait for submission print(f"{good} Facebook account created for {person_data['name']}") diff --git a/requirements.txt b/requirements.txt index e13e29c..0c7c6ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,5 @@ gender_guesser==0.4.0 numpy==1.23.4 opencv_python==4.6.0.66 requests==2.25.1 +selenium>=4.0.0 +webdriver-manager>=4.0.0