I can't seem to open up Google Chrome or Internet Explorer through Selenium 2's Python library. I am using Windows 7, 64 bit.
I have completed the following steps:
Whenever I type:
from selenium import webdriver
driver = webdriver.Ie()
OR
from selenium import webdriver
driver = webdriver.Chrome()
into the Python shell, no browser pops up, the shell just freezes for a couple of minutes and then outputs an error message.
IE Error message:
selenium.common.exceptions.WebDriverException: Message: 'Can not connect to the IEDriver'
Chrome Error message:
urllib2.HTTPError: HTTP Error 503: Service Unavailable
It works perfectly fine with firefox. The funny thing is, is that the process (IEDriver and ChromeDriver) starts per the TaskManager, but the window never shows up.
In python-selenium webdriver.Ie
is just a shortcut for executing IEDriver.exe and connecting to it through webdriver.Remote
. For example, you could start IEDriver.exe from command line:
> IEDriverServer.exe
Started InternetExplorerDriver server (64-bit)
2.39.0.0
Listening on port 5555
and replace webdriver.Ie()
with the following code:
webdriver.Remote(command_executor='http://127.0.0.1:5555',
desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)`
You will get the same result.
Specifically in your case is most likely that you have some system proxy settings that force it connect to 127.0.0.1 through proxy server. Probably when you disable it as described in answer Python: Disable http_proxy in urllib2, you can solve the problem:
import selenium
import urllib2
from contextlib import contextmanager
@contextmanager
def no_proxies():
orig_getproxies = urllib2.getproxies
urllib2.getproxies = lambda: {}
yield
urllib2.getproxies = orig_getproxies
with no_proxies():
driver = selenium.webdriver.Ie()
driver.get("http://google.com")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With