Firefox, Python. AttributeError: type object 'Options' has no attribute '_ignore_local_proxy'

800 views
Skip to first unread message

Kira Lyubimova

unread,
Jan 2, 2023, 10:13:29 AM1/2/23
to Selenium Users
Hello!
I've just started learning selenium and already run into an issue.
I try to start a session and quit it but get an error message:

(selenium_tests_env) PS C:\disk\auto\selenium_tests> python .\tests\sessions.py
C:\disk\auto\selenium_tests\tests\sessions.py:7: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Firefox(executable_path=r'C:\WebDrivers\geckodriver.exe', options=options)
Traceback (most recent call last):
  File "C:\disk\auto\selenium_tests\tests\sessions.py", line 7, in <module>
    driver = webdriver.Firefox(executable_path=r'C:\WebDrivers\geckodriver.exe', options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\disk\auto\selenium_tests\selenium_tests_env\Lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 195, in __init__
    remote_server_addr=self.service.service_url, ignore_proxy=options._ignore_local_proxy
                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Options' has no attribute '_ignore_local_proxy'



My code is:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options
options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'

driver = webdriver.Firefox(executable_path=r'C:\WebDrivers\geckodriver.exe', options=options)
driver.quit()


Any ideas are welcome.
Thank you in advance.

Kira Lyubimova

unread,
Jan 2, 2023, 10:21:55 AM1/2/23
to Selenium Users
System: Windows 10
Selenium: 4.7.2
Python: 3.11.0
Geckodriver: 0.32.0

Kira Lyubimova

unread,
Jan 2, 2023, 11:59:00 AM1/2/23
to Selenium Users
SOLVED

The issue was fixed with two lines of code.
1. options = Options
    This line is wrong. Should be: options = Options()
     Parenthesis matter! "Parentheses create a new object; no parentheses refers to the class of object itself."
     Solution found here.
2. options.ignore_local_proxy_environment_variables()
    This line solved the key problem.
    Solution found here.


Final working code:

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()

options.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'
options.ignore_local_proxy_environment_variables()
Reply all
Reply to author
Forward
0 new messages