Closed michelecampobasso closed 2 years ago
Thanks so much for the pull request @michelecampobasso . Would it be possible to share a code snippet that triggers this issue?
self.tbb_profile_path
should already contain the custom profile path, but maybe I'm missing something:
https://github.com/webfp/tor-browser-selenium/blob/main/tbselenium/tbdriver.py#L174
Hey @gunesacar, sure. First, copy your tbprofile to a custom location (e.g. ~/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/Browser/TorBrowser/Data/Browser/profile.default
to /tmp/curprofile
)
By simply invoking:
driver = TorBrowserDriver("~/.local/share/torbrowser/tbb/x86_64/tor-browser_en-US/", tbb_logfile_path=os.devnull, tbb_profile_path="/tmp/curprofile", use_custom_profile=True)
you can see that line 55 on tbdriver.py
will call self.setup_tbb_paths
. This function always computes the default profile path (line 166), and assigns it to self.tbb_profile_path
at line 174. After execution, the constructor at line 64 verifies that use_custom_profile
is True but assigns the computed default value contained in self.tbb_profile_path
rather than the user specified tbb_profile_path
.
Thanks so much for the explanation. Now it's clear what the problem is: setup_tbb_paths
expects either a tbb_path
, or both binary and profile paths (link).
When the caller provides tbb_path
along with a custom tbb_profile_path
, we don't give the priority to the most specific argument (tbb_profile_path
), and use the default profile path in the TBB folder.
One note about the pull request: can we fix this in setup_tbb_paths
? That method should be responsible for setting the correct paths. If you don't have time, let me know and I'll fix it myself.
Thank you.
Agree, done. However, I'm not entirely sure why when tbb_path
is specified tbb_profile
is ignored. In my commit I've introduced the possibility to simply specify the additional profile alongside tbb_path
, as one may want to stick to the default installation of TB while specifying a different profile.
Let me know if there is something I'm missing or that would be useful as well.
Thanks!
However, I'm not entirely sure why when
tbb_path
is specifiedtbb_profile
is ignored.
Indeed, it's an oversight. We should use the tbb_profile
when it's given. I'll merge your commit, but I first need to add some comments.
Thanks so much.
On an additional note: the whole use of the flag this.use_custom_profile
could be deprecated; as a matter of fact, it is sufficient to specify a profile path to use it.
If you agree, I can modify and push these changes.
Thanks for maintaining this project!
Thanks so much. Merged. I added a few tests: https://github.com/webfp/tor-browser-selenium/commit/22ced313bfabf608f554794b9da549a98502f0f4
The use_custom_profile
is still useful to signal whether the caller only wants to read from (clone) a custom profile, or write into it as well.
Fixed a bug in which the path of a specified custom profile was ignored.