webfp / tor-browser-selenium

Tor Browser automation with Selenium.
MIT License
528 stars 101 forks source link

FileNotFoundError when providing only tbb_fx_binary_path and tbb_profile_path #159

Closed baum314nk closed 2 years ago

baum314nk commented 2 years ago

First of all: Thanks for this easy to use integration of Tor Browser into Selenium :)

When providing only tbb_fx_binary_path and tbb_profile_path to the TorBrowserDriver constructor, I get an FileNotFoundError. I traced the problem back to the setup_tbb_paths method in tbdriver.py. The last line there wants to change the current dir to the tbb_browser_dir which is constructed using tbb_path which is empty as it wasn't given.

I did a dirty fix that may be useful for fixing the bug (starting at line 119 of tbdriver.py):

if tbb_path:
    ...
else:
    tbb_path = abspath(join(tbb_fx_binary_path, '../..'))
lvwuwei commented 2 years ago

Traceback (most recent call last): File "tor1.py", line 2, in with TorBrowserDriver("/root/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/") as driver: File "/usr/local/lib/python3.8/dist-packages/tbselenium/tbdriver.py", line 53, in init self.setup_capabilities(capabilities) File "/usr/local/lib/python3.8/dist-packages/tbselenium/tbdriver.py", line 255, in setup_capabilities self.capabilities = { AttributeError: can't set attribute

gunesacar commented 2 years ago

Thank you @baum314nk for reporting and @lvwuwei for the comment. I'm working on making the library compatible with Selenium 4, which may also affect how profiles are handled. I'll circle back to this issue afterwards.