fix: update social_media.py to Selenium 4 API and add missing deps#6
Open
cluster2600 wants to merge 1 commit intomalwaredojo:mainfrom
Open
fix: update social_media.py to Selenium 4 API and add missing deps#6cluster2600 wants to merge 1 commit intomalwaredojo:mainfrom
cluster2600 wants to merge 1 commit intomalwaredojo:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
loki/core/social_media.pyto use the Selenium 4find_element(By.*, ...)APIseleniumandwebdriver-managertorequirements.txt(they were missing)Why
Selenium 4 removed the legacy shorthand methods like
find_element_by_name()andfind_element_by_css_selector()that were deprecated in Selenium 3. Any user runningpip install -r requirements.txtand then using the-soc/--social-createflag will encounter two errors:ImportError–seleniumandwebdriver-managerare imported insocial_media.pybut not listed inrequirements.txtAttributeError: 'WebDriver' object has no attribute 'find_element_by_name'– Selenium 4 removed these legacy methodsHow
loki/core/social_media.py:from selenium.webdriver.common.by import Byfind_element_by_name(x)→find_element(By.NAME, x)find_element_by_css_selector(x)→find_element(By.CSS_SELECTOR, x)requirements.txt:selenium>=4.0.0webdriver-manager>=4.0.0Testing
find_element_by_*patterns replaced with the currentfind_element(By.*, ...)APIChecklist