webfp / tor-browser-selenium

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

headless keyword is raising AttributeError #164

Closed tiovader closed 2 years ago

tiovader commented 2 years ago
  File "~/main.py", line 51, in <module>
    bot_vote()
  File "~/main.py", line 23, in bot_vote
    with TorBrowserDriver(PATH, headless=True, tbb_logfile_path='/dev/null') as driver:
  File "~/.venv/lib/python3.9/site-packages/tbselenium/tbdriver.py", line 59, in __init__
    options.set_headless()
AttributeError: 'Options' object has no attribute 'set_headless'

At line 59 it raises an AttributeError, I could solve it by changing line 58 and 59 to this: options.headless = headless

Apparently it has changed? I'm using selenium 4.1.0, and seeking into headless it is using property, and has a setter function.

    @headless.setter
    def headless(self, value: bool):
        """
        Sets the headless argument

        Args:
          value: boolean value indicating to set the headless option
        """
        if value:
            self._arguments.append('-headless')
        elif '-headless' in self._arguments:
            self._arguments.remove('-headless')
gunesacar commented 2 years ago

Thank so much for reporting. Looks like this was changed in Selenium 4 (or earlier). I'll fix it in the new release.

gunesacar commented 2 years ago

Should be fixed in https://github.com/webfp/tor-browser-selenium/pull/166. Closing.