javax.net.ssl.SSLException:收到致命警报:使用Selenium

时间:2016-01-13 08:31:20

标签: java selenium ssl

运行selenium脚本时收到此错误

  

org.openqa.selenium.WebDriverException:javax.net.ssl.SSLException:收到致命警报:protocol_version

下面的堆栈跟踪:

  

驱动程序信息:driver.version:HtmlUnitDriver       at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)       at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)       at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1979)       at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1086)       at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332)       at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359)       at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343)       at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)       at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)       在com.gargoylesoftware.htmlunit.httpclient.HtmlUnitSSLConnectionSocketFactory.connectSocket(HtmlUnitSSLConnectionSocketFactory.java:189)       at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)       at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)       at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)       在org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)       在org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)       在org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)       在org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)       在org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)       在org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)       在com.gargoylesoftware.htmlunit.HttpWebConnection.getResponse(HttpWebConnection.java:179)       在com.gargoylesoftware.htmlunit.WebClient.loadWebResponseFromWebConnection(WebClient.java:1321)       在com.gargoylesoftware.htmlunit.WebClient.loadWebResponse(WebClient.java:1238)       在com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:346)       在com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:415)       在org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:541)       在org.openqa.selenium.htmlunit.HtmlUnitDriver.get(HtmlUnitDriver.java:530)       在com.mimos.performance.PerfTest.PerfTest(PerfTest.java:34)

构建信息:版本:&#39; 2.48.2&#39;,修订版:&#39; 41bccdd10cf2c0560f637404c2d96164b67d9d67&#39;,时间:&#39; 2015-10-09 13:08:06&#39; < / p>

java version&#34; 1.7.0_79&#34; Java(TM)SE运行时环境(版本1.7.0_79-b15) Java HotSpot(TM)64位服务器VM(内置24.79-b02,混合模式)

    HtmlUnitDriver driver = new HtmlUnitDriver();        
    driver.get(url);
    WebElement passwordLogo = driver.findElement(By.xpath("/html/body/div[1]/div/div[2]/div/ul/li/a"));
    passwordLogo.click();
    WebElement userID = driver.findElement(By.xpath("/html/body/div/form[1]/input[1]"));
    userID.sendKeys(username);
    WebElement next = driver.findElement(By.xpath("/html/body/div/form[1]/input[2]"));
    next.click();
    WebElement password =  driver.findElement(By.xpath("/html/body/div/form[1]/div/input[1]"));
    password.sendKeys(password);
    WebElement login = driver.findElement(By.xpath("/html/body/div/form[1]/div/input[3]"));
    login.click();
    System.out.println(driver.getTitle());

1 个答案:

答案 0 :(得分:0)

早上好。可能与 javax.net.ssl.SSLException: Received fatal alert: protocol_version

相关
  

这似乎是协议版本不匹配,当客户端使用的SSL协议版本与服务器不匹配时,通常会发生此异常。您的客户应使用服务器支持的proctocol版本。