Code unreachable when adding Selenium ChromeOptions

Issue

For some reason my Python code displays as unreachable after adding a series of WebDriver options. Does anyone know why this is happening and how it can be fixed?
enter image description here

Code itself is below:

class DriverOptions(object):

  def __init__(self):

    self.options = Options()
    self.options.add_argument('--no-sandbox')
    self.options.add_argument('--start-maximized')
    self.options.add_argument('--start-fullscreen')
    self.options.add_argument('--single-process')
    self.options.add_argument('--disable-dev-shm-usage')
    self.options.add_argument("--incognito")
    self.options.add_argument('--disable-blink-features=AutomationControlled')
    self.options.add_argument('--disable-blink-features=AutomationControlled')
    self.options.add_experimental_option('useAutomationExtension', False)
    self.options.add_experimental_option("excludeSwitches", ["enable-automation"])
    self.options.add_argument("disable-infobars")

    self.helperSpoofer = Spoofer()

    self.options.add_argument('user-agent={}'.format(self.helperSpoofer.userAgent))
    self.options.add_argument('--proxy-server=%s' % self.helperSpoofer.ip)

Solution

There is a bug in Selenium 4.0. Just try updating your pip and simply uninstalling the selenium and reinstalling it. It solved a problem for me.

pip install selenium --upgrade

Answered By – Jay Thorat

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published