-
Notifications
You must be signed in to change notification settings - Fork 105
fix: replace FirefoxBinary with Selenium 4 equivalents (fixes #222) #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,22 @@ | ||
| from selenium.webdriver.firefox.firefox_binary import FirefoxBinary | ||
| import subprocess | ||
|
|
||
|
|
||
| class TBBinary(FirefoxBinary): | ||
| class TBBinary: | ||
| ''' | ||
| Extend FirefoxBinary to better handle terminated browser processes. | ||
| Manage the Tor Browser (Firefox) binary process. | ||
|
|
||
| FirefoxBinary was removed in Selenium 4. This class replaces the previous | ||
| TBBinary(FirefoxBinary) subclass and provides only the process-management | ||
| functionality that tbselenium relies on internally. | ||
| ''' | ||
|
|
||
| def kill(self): | ||
| """Kill the browser. | ||
| def __init__(self, firefox_path=None, log_file=None): | ||
| self.firefox_path = firefox_path | ||
| self.log_file = log_file | ||
| self.process = None | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] Problem — Failure scenario — A caller uses Fix — If log redirection is out of scope for this PR, remove the |
||
|
|
||
| This is useful when the browser is stuck. | ||
| """ | ||
| def kill(self): | ||
| """Kill the browser process if it is still running.""" | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Blocking] Problem — The presence of Failure scenario — A user calls Fix — Either implement a |
||
| if self.process and self.process.poll() is None: | ||
| self.process.kill() | ||
| self.process.wait() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion]
Problem —
import subprocessis added at the top of the file but is never used anywhere in the module. The newTBBinaryclass has nolaunch_browser()or similar method that callssubprocess.Popen. This dead import will triggerflake8 F401lint errors and misleads readers into thinkingTBBinaryis responsible for spawning the browser process.Failure scenario — Any CI pipeline running
flake8will flag this and fail. A developer reading the file will naturally look for wheresubprocessis used and waste time concluding it was an incomplete implementation.Fix — Remove
import subprocess. If alaunch_browser()method is added in a follow-up, the import can be restored then.