I am trying to run selenium code for chrome browser in python but facing below issue. I am providing the proxy server details correctly and providing the chrome driver path. But the webdriver.Chrome is throwing access denied error.
Python 3.12
Selenium version: 4.18.1
urllib3 version: 2.2.1
Chrome driver version: 96.0.4664.45
Code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
service = Service(executable_path=chrome_driver_path)
options = webdriver.ChromeOptions()
options.add_argument(f'--proxy-server={http_proxy}')
driver = webdriver.Chrome(service=service, options=options)
Error Message:
selenium.common.exceptions.WebDriverException: Message: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta type="copyright" content="Copyright (C) 1996-2015 The Squid Software Foundation and contributors">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!--
/*
* Copyright (C) 1996-2016 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
/*
Stylesheet for Squid Error pages
Adapted from design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
.....
</head><body id=ERR_ACCESS_DENIED>
<div id="titles">
<h1>ERROR</h1>
<h2>The requested URL could not be retrieved</h2>
</div>
<hr>
<div id="content">
<p>The following error was encountered while trying to retrieve the URL: <a href="http://localhost:58280/session">http://localhost:58280/session</a></p>
<blockquote id="error">
<p><b>Access Denied.</b></p>
</blockquote>
Checked the proxy configurations are correct
I tried using selenium version 3.14
Tried setting to no_proxy
Rahul Lulla is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.