Unable to open URLs using python webdriver for selenium 2.0
I am new to both Python as well as Selenium and and still in the learning phase. I have been trying to launch both IE8 as well as Firefox using the new Python Webdriver for Selenium with the following code.
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
driver = webdriver.Ie()
#driver = webdriver.Firefox()
driver.get("http://www.google.com")
In case of Firefox, it launches the broswer with my home page while it does not even launch the IE8 browser.
In either case I can see this exception in my command prompt window.
File "C:\Documents and Settings\user.name\My Documents\seleniumScripts\test1.py",
line > 8, in <module>
driver = webdriver.Ie()
File "C:\Python27\lib\site-packages\selenium-2.7.0
-py2.7.egg\selenium\webdriver\ie\webdriver.py", line 58, in __init_
desired_capabilities=DesiredCapabilities.INTERNETEXPLORER)
File "C:\Python27\lib\site-packages\selenium-2.7.0-
py2.7.egg\selenium\webdriver\remote\webdriver.py", line 61, in __i
it__self.start_session(desired_capabilities, browser_profile)
File "C:\Python27\lib\site-packages\selenium-2.7.0
- py2.7.egg\selenium\webdriver\remote\webdriver.py", line 98, in sta
t_session
'desiredCapabilities': desired_capabilities,
File "C:\Python27\lib\site-packages\selenium-2.7.0-
py2.7.egg\selenium\webdriver\remote\webdriver.py", line 144, in excute
self.error_handler.check_response(response)
File "C:\Python27\lib\site-packages\selenium-2.7.0-
py2.7.egg\selenium\webdriver\remote\errorhandler.py", line 100,
in check_response
raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: '<!DOCTYPE HTML PUBLIC "- //W3C//DTD HTML 4.0 Transitional//EN"&g开发者_Python百科t;
r\n<HTML><HEAD><TITLE>Error Message</TITLE>\r\n<META http-equiv=Content-Type
content="text/html; charset=UTF-8">\r\n<ST
LE id=L_default_1>A {\r\n\tFONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #005a80; FONT- FAMILY: tahoma\r\n}\r\nA:hover {\r\
\tFONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #0d3372; FONT-FAMILY: tahoma\r\n}\r\nTD
{\r\n\tFONT-SIZE: 8pt; FONT-FAMILY
tahoma\r\n}\r\nTD.titleBorder {\r\n\tBORDER-RIGHT: #955319 1px solid; BORDER-TOP:
#955319 1px solid; PADDING-LEFT: 8px
FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 0px
solid; COLOR: #955319; BORDER-BOT
OM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a;
TEXT-ALIGN: left\r\n}\r\nTD.titleB
rder_x {\r\n\tBORDER-RIGHT: #955319 0px solid; BORDER-TOP: #955319 1px solid; PADDING- LEFT: 8px; FONT-WEIGHT: bold; FON
-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 1px solid; COLOR: #978c79;
BORDER-BOTTOM: #955319 1px solid;
ONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left\r\n}
\r\n.TitleDescription {\r\n\tFONT-WEI
HT: bold; FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: tahoma\r\n}
\r\nSPAN.explain
{\r\n\tFONT-WEIGHT: normal; FONT-SIZE
10pt; COLOR: #934225\r\n}\r\nSPAN.TryThings {\r\n\tFONT-WEIGHT: normal; FONT-SIZE:
10pt;
COLOR: #934225\r\n}\r\n.TryLi
t {\r\n\tMARGIN-TOP: 5px; FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY:
tahoma\r\n}\r\n.X {\r\n\tBORD
R-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; FONT-WEIGHT: normal; FONT-
SIZE: 12pt; BORDER-LEFT: #955319 1
x solid; COLOR: #7b3807; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: verdana;
BACKGROUND-COLOR: #d1c2b4\r\n}\r\n.adm
nList {\r\n\tMARGIN-TOP: 2px\r\n}\r\n</STYLE>\r\n<META content="MSHTML 6.00.2800.1170"
name=GENERATOR></HEAD>\r\n<BODY
gColor=#f3f3ed>\r\n<TABLE cellSpacing=0 cellPadding=0 width="100%">\r\n <TBODY>\r\n
<TR>\r\n <TD class=titleborder
x width=30>\r\n <TABLE height=25 cellSpacing=2 cellPadding=0 width=25
bgColor=black>\r\n <TBODY>\r\n
<TR>\r\n <TD class=x vAlign=center align=middle>X</TD>\r\n
</TR>\r\n </TBODY>\r\n </TABLE>\
\n </TD>\r\n <TD class=titleBorder id=L_default_2>Network Access Message:<SPAN
class=TitleDescription> The page cannot be displayed</SPAN> </TD>\r\n </TR>\r\n
</TBODY>\r\n</TABLE>\r\n\r\n<TABLE id=spacer>\r\n <TBODY>\r\n <TR>\r\n
<TD height=10></TD></TR></TBODY></TABLE>\r\n<TABLE width=400>\r\n <TBODY>\r\n
<TR>\r\n
<TD noWrap width=25></TD\r\n <TD width=400><SPAN class=explain><ID
id=L_default_3><B>Explanation:</B></ID></SPAN><ID id=L_default_4> There i
a problem with the page you are trying to reach and it cannot be displayed.
</ID><BR><BR>\r\n <B><SPAN class=tryThi
gs><ID id=L_default_5><B>Try the following:</B></ID></SPAN></B> \r\n <UL
class=TryList>\r\n <LI id=L_defaul
_6><B>Refresh page:</B> Search for the page again by clicking the Refresh button. The
timeout may have occurred due to
nternet congestion.\r\n<LI id=L_default_7><B>Check spelling:</B> Check that you typed
the Web page address correctly. The address may have been mistyped.\r\n<LI
id=L_default_8><B>Access from a link:</B> If
there is a link to the page you a
e looking for, try accessing the page from that link.\r\n\r\n </UL>\r\n<ID
id=L_default_9>If you are still not abl
to view the requested page, try contacting your administrator or Helpdesk.</ID>
<BR><BR>\r\n </TD>\r\n </TR>\r\n
/TBODY>\r\n</TABLE>\r\n\r\n<TABLE id=spacer><TBODY><TR><TD
height=15></TD></TR></TBODY></TABLE>\r\n\r\n<TABLE width=400
\r\n <TBODY>\r\n <TR>\r\n <TD noWrap width=25></TD>\r\n <TD width=400
id=L_default_10><B>Technical Information
for support personnel)</B> \r\n <UL class=adminList>\r\n <LI
id=L_default_11>Error Code: 407 Proxy Authenti
ation Required. The ISA Server requires authorization to fulfill the request. Access to
the Web Proxy filter is denied.
(12209)\r\n<LI id=L_default_12>IP Address: 11.1.11.111\r\n<LI id=L_default_13>Date:
9/30/2011 3:23:59 PM [GMT]\r\n<LI i
=L_default_14>Server: servername.com\r\n<LI id=L_default_15>Source: proxy\r\n\r\n
</UL>\r\n </TD>
r\n </TR>\r\n </TBODY>\r\n</TABLE>\r\n\r\n</BODY>\r\n</HTML>\r\n\r\n'
ANy help would be really appeciated as I am completely stuck and kind of desperate now.
Thanks
精彩评论