无法创建新的Firefox Webdriver Selenium Mac OS 10.9.5,Firefox 39.0

时间:2015-07-15 18:38:59

标签: java macos firefox selenium

我正在尝试运行selenium java 2.45.0。我试图在java中简单地创建一个新的Webdriver对象:

WebDriver driver = new FirefoxDriver();

但是失败并带有以下痕迹:

Exception in thread "main" org.openqa.selenium.WebDriverException: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Error Message</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<STYLE id=L_default_1>A {
    FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #005a80; FONT-FAMILY: tahoma
}
A:hover {
    FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #0d3372; FONT-FAMILY: tahoma
}
TD {
    FONT-SIZE: 8pt; FONT-FAMILY: tahoma
}
TD.titleBorder {
    BORDER-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-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left
}
TD.titleBorder_x {
    BORDER-RIGHT: #955319 0px solid; BORDER-TOP: #955319 1px solid; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 12pt; VERTICAL-ALIGN: middle; BORDER-LEFT: #955319 1px solid; COLOR: #978c79; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: tahoma; HEIGHT: 35px; BACKGROUND-COLOR: #d2b87a; TEXT-ALIGN: left
}
.TitleDescription {
    FONT-WEIGHT: bold; FONT-SIZE: 12pt; COLOR: black; FONT-FAMILY: tahoma
}
SPAN.explain {
    FONT-WEIGHT: normal; FONT-SIZE: 10pt; COLOR: #934225
}
SPAN.TryThings {
    FONT-WEIGHT: normal; FONT-SIZE: 10pt; COLOR: #934225
}
.TryList {
    MARGIN-TOP: 5px; FONT-WEIGHT: normal; FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: tahoma
}
.X {
    BORDER-RIGHT: #955319 1px solid; BORDER-TOP: #955319 1px solid; FONT-WEIGHT: normal; FONT-SIZE: 12pt; BORDER-LEFT: #955319 1px solid; COLOR: #7b3807; BORDER-BOTTOM: #955319 1px solid; FONT-FAMILY: verdana; BACKGROUND-COLOR: #d1c2b4
}
.adminList {
    MARGIN-TOP: 2px
}
</STYLE>
<META content="MSHTML 6.00.2800.1170" name=GENERATOR></HEAD>
<BODY bgColor=#f3f3ed>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
  <TBODY>
  <TR>
    <TD class=titleborder_x width=30>
      <TABLE height=25 cellSpacing=2 cellPadding=0 width=25 bgColor=black>
        <TBODY>
        <TR>
          <TD class=x vAlign=center align=middle>X</TD>
        </TR>
        </TBODY>
      </TABLE>
    </TD>
    <TD class=titleBorder id=L_default_2>Network Access Message:<SPAN class=TitleDescription> The page cannot be displayed</SPAN> </TD>
  </TR>
  </TBODY>
</TABLE>

<TABLE id=spacer>
  <TBODY>
  <TR>
    <TD height=10></TD></TR></TBODY></TABLE>
<TABLE width=400>
  <TBODY>
  <TR>
    <TD noWrap width=25></TD>
    <TD width=400><SPAN class=explain><ID id=L_default_3><B>Explanation:</B></ID></SPAN><ID id=L_default_4> There is a problem with the page you are trying to reach and it cannot be displayed. </ID><BR><BR>
    <B><SPAN class=tryThings><ID id=L_default_5><B>Try the following:</B></ID></SPAN></B> 
      <UL class=TryList>
        <LI id=L_default_6><B>Refresh page:</B> Search for the page again by clicking the Refresh button. The timeout may have occurred due to Internet congestion.
<LI id=L_default_7><B>Check spelling:</B> Check that you typed the Web page address correctly. The address may have been mistyped.
<LI id=L_default_8><B>Access from a link:</B> If there is a link to the page you are looking for, try accessing the page from that link.

      </UL>
<ID id=L_default_9>If you are still not able to view the requested page, try contacting your administrator or Helpdesk.</ID> <BR><BR>
    </TD>
  </TR>
  </TBODY>
</TABLE>

<TABLE id=spacer><TBODY><TR><TD height=15></TD></TR></TBODY></TABLE>

<TABLE width=400>
  <TBODY>
  <TR>
    <TD noWrap width=25></TD>
    <TD width=400 id=L_default_10><B>Technical Information (for support personnel)</B> 
      <UL class=adminList>
        <LI id=L_default_11>Error Code: 502 Proxy Error. The ISA Server denied the specified Uniform Resource Locator (URL). (12202)
<LI id=L_default_12>IP Address: 10.9.1.80
<LI id=L_default_13>Date: 15/07/2015 18:23:46
<LI id=L_default_14>Server: proxy02
<LI id=L_default_15>Source: proxy

      </UL>
    </TD>
  </TR>
  </TBODY>
</TABLE>

</BODY>
</HTML>
Command duration or timeout: 403 milliseconds
Driver info: org.openqa.selenium.firefox.FirefoxDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:240)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:126)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:191)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>

有没有人想过为什么会这样?我使用的是selenium 2.45.0,Mac OS 10.9.5,jdk 1.7.0_76,firefox 39.0。我的firefox安装在/Applications/Firefox.app

谢天谢地, 杰森

2 个答案:

答案 0 :(得分:0)

无法创建新的Firefox Webdriver Selenium Mac OS 10.9.5,Firefox 39.0:

将您的firefox以及selenium jar文件更新为最新版本。它会起作用:))

答案 1 :(得分:0)

通过添加System.setProperty(&#34; java.net.preferIPv4Stack&#34;,&#34; true&#34;)来解决这个问题;

或在JVM启动时设置vm参数