0

I want to use Selenium Webdriver and I am unable to do so because when I run my code, I get the following exception. My code is very basic and as follows.

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com.bh")
assert "Google" in driver.title
driver.close()

Exception Message
selenium.common.exceptions.WebDriverException: Message: '<HTML><HEAD>\n<TITLE>Access Denied</TITLE>\n</HEAD>\n<BODY>\n<FONT face="Helvetica">\n<big><strong></strong></big><BR>\n</FONT>\n<blockquote>\n<TABLE border=0 cellPadding=1 width="80%">\n<TR><TD>\n<FONT face="Helvetica">\n<big>Access Denied (authentication_failed)</big>\n<BR>\n<BR>\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica">\nYour credentials could not be authenticated: "Credentials are missing.". You will not be permitted access until your credentials can be verified.\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica">\nThis is typically caused by an incorrect username and/or password, but could also be caused by network problems.\n</FONT>\n</TD></TR>\n<TR><TD>\n<FONT face="Helvetica" SIZE=2>\n<BR>\nFor assistance, contact your network support team.\n</FONT>\n</TD></TR>\n</TABLE>\n</blockquote>\n</FONT>\n</BODY></HTML>\n' 

It opens firefox but after that it is unable to connect to google or any other local sites. The exception is at driver = webdriver.Firefox()

I googled around and I followed the link on SO.

But unfortunately I still get the same error. I cannot run as the root user. I changed my proxy settings and set No Proxy element for localhost as well as mentioned in the link.

I am using Python 2.7 and have installed selenium 2.31 version.

I also tried setting proxy.

myProxy = "*********:8080"
proxy = Proxy({
    'proxyType': ProxyType.MANUAL,
    'httpProxy': myProxy,
    'ftpProxy': myProxy,
    'sslProxy': myProxy,
    'noProxy': 'localhost,127.0.0.1,*.abc' 
    })

driver = webdriver.Firefox(proxy=proxy)

I also tried to set the proxy to system's proxy i.e., in the above code, 'proxyType': ProxyType.SYSTEM

But it again gives the above exception message. is there a place where I have to set my username and password?

Any help would be appreciated!

Community
  • 1
  • 1
Rashmi Nagaraja
  • 801
  • 11
  • 20

1 Answers1

0

Remove proxy settings from all the browsers on the system manually. I had IE, Firefox and Google Chrome. When I removed the proxy settings of all the browsers and enabled the proxy only on Firefox,it worked without giving any errors. I do not know the exact reason why this works like this, may be got to do with the registry settings on windows which I am not sure about. After doing the above said, I ran the basic code and it worked fine.

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com.bh")
assert "Google" in driver.title
driver.close()

I didn't set the proxy explicitly also. By default, it had taken the system's proxy settings. Hope this would help others facing similar issue.

Rashmi Nagaraja
  • 801
  • 11
  • 20