I am trying to use python
and selenium
to run some tests in Internet Explorer using IEDriverServer.exe
with protection mode turned off. When I try with the Google Chrome driver, it operates as expected.
CODE
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
iedriver = "C:\Program Files\Internet Explorer\IEDriverServer.exe"
os.environ["webdriver.ie.driver"] = iedriver
driver.get("http://www.baidu.com")
ERROR
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
driver.get("http://www.baidu.com")
NameError: name 'driver' is not defined
>>> driver = webdriver.Ie(iedriver)
Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
driver = webdriver.Ie(iedriver)
File "F:\Python27\lib\site-packages\selenium\webdriver\ie\webdriver.py", line 57, in __init__
desired_capabilities=capabilities)
File "F:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "F:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "F:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 234, in execute
response = self.command_executor.execute(driver_command, params)
File "F:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 408, in execute
return self._request(command_info[0], url, body=data)
File "F:\Python27\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 478, in _request
resp = opener.open(request, timeout=self._timeout)
File "F:\Python27\lib\urllib2.py", line 429, in open
response = self._open(req, data)
File "F:\Python27\lib\urllib2.py", line 447, in _open
'_open', req)
File "F:\Python27\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "F:\Python27\lib\urllib2.py", line 1228, in http_open
return self.do_open(httplib.HTTPConnection, req)
File "F:\Python27\lib\urllib2.py", line 1201, in do_open
r = h.getresponse(buffering=True)
File "F:\Python27\lib\httplib.py", line 1136, in getresponse
response.begin()
File "F:\Python27\lib\httplib.py", line 453, in begin
version, status, reason = self._read_status()
File "F:\Python27\lib\httplib.py", line 417, in _read_status
raise BadStatusLine(line)
BadStatusLine: ''