WebDriverException - Error 403

95 views
Skip to first unread message

Michael Mass

unread,
Feb 7, 2023, 12:57:03 PM2/7/23
to Selenium Users
Python 3.10.5
Selenium 4.8.0
Windows 10 Enterprise

I am unable to create a webdriver object.

My code:
from selenium import webdriver
from selenium.webdriver.chome.service import Service

browser = webdriver.Chrome(service=Service(R"C:\ProgramData\Google\ChromeDriver\chromedriver.exe"))

The error:
On that last line, I get a WebDriverException and after setting "justMyCode" to false, I get the following error details:
Exception has occurred: WebDriverException (note: full exception trace is shown but execution paused at: _run_module_as_main)
Message: <!DOCTYPE html>
<body>
</body>
</html>
  File "..\webdriver\remote\errorhandler.py", line 209, in check_response
    raise exception_class(value)
  File "..\webdriver\remote\webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "..\webdriver\remote\webdriver.py", line 378, in start_session
    response = self.execute(Command.NEW_SESION, parameters)
  File "..\webdriver\remote\webdriver.py", line 286, in __init__
    self.start_session(capabilities, browser_profile)
  File "..\webdriver\chromium\webdriver.py", line 104, in __init__
    super().__init__(
  File "..\webdriver\chrome\webdriver.py", line 80 in __init__
    super().__init__(
  File "main.py", line 36, in <module>
    driver = webdriver.Chrome(service=Service(R"C:\ProgramData\Google\ChromeDriver\chromedriver.exe"))
  File "C:\Program Files\Python310\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Lib\runpy.py", line 196, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
selenium.common.execptions.WebDriverException: Message: <!DOCTYPE html>
<body>
</body>
</html>

Note: All above file paths shortened because I had to type this out by hand due to paste operations being prohibited on this site at my office. Crazy about security here. All the paths are to the "..\AppData\Roaming\Python\Python310\site-packages\selenium\webdriver" folder.

Stepping through it some more and seeing other variables, I'm getting a 403 response code from the basic connection localhost url that selenium creates, and that is what kicks back that WebDriverException error.

Solutions I've tried:
- all mess of different Chrome Options that I've found when Googling the error
- uninstalling and reinstalling Python and Selenium
- downgrading Selenium to the previous version
- Edge instead of Chrome
- reinstalling the drivers

Also important to note that I'm on a work computer so I'm unable to install different versions of Chrome/Edge or the associated drivers.
Reply all
Reply to author
Forward
0 new messages