首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >硒NoClassDefFoundError用于SSLContext

硒NoClassDefFoundError用于SSLContext
EN

Stack Overflow用户
提问于 2017-02-08 00:34:01
回答 2查看 1.6K关注 0票数 1

我对硒测试很陌生。在使用一个网站时,我得到了一个错误: org/apache/http/ssl/SSLContexts:"main“java.lang.NoClassDefFoundError

你能帮帮我吗?

这里是我的示例代码

代码语言:javascript
运行
复制
public class TutorialsPointDownload {   
    public static void main(String[] args) {
            FirefoxProfile profile = new FirefoxProfile();
        profile.setAcceptUntrustedCertificates(true);
        profile.setAssumeUntrustedCertificateIssuer(false);
        WebDriver driver = new FirefoxDriver(profile);
        driver.get("https://www.tutorialspoint.com/software_testing_dictionary/acceptance_testing.htm");
        driver.findElement(By.xpath("/html/body/div[3]/div[1]/div/div[1]/aside/div[2]/div/ul[1]"));
        List<WebElement> we = driver.findElements(By.tagName("a"));
        System.out.println(we.size());
     }
}

控制台输出

代码语言:javascript
运行
复制
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/ssl/SSLContexts
    at org.apache.http.conn.ssl.SSLConnectionSocketFactory.getSocketFactory(SSLConnectionSocketFactory.java:172)
    at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:57)
    at org.openqa.selenium.remote.internal.HttpClientFactory.<init>(HttpClientFactory.java:60)
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:252)
    at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.<init>(ApacheHttpClient.java:229)
    at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:70)
    at org.openqa.selenium.remote.HttpCommandExecutor.<init>(HttpCommandExecutor.java:58)
    at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:87)
    at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:119)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:216)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:207)
    at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
    at TutorialsPointDownload.main(TutorialsPointDownload.java:57)
Caused by: java.lang.ClassNotFoundException: org.apache.http.ssl.SSLContexts
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 17 more

添加依赖项:

代码语言:javascript
运行
复制
<dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.3.3</version>
    </dependency>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-02-08 00:43:54

发生此问题的原因是SSLContext已被重新部署到httpClient >= 4.4中的另一个包中。因此,我们需要将httpCore依赖项升级到4.4或任何新版本。

票数 2
EN

Stack Overflow用户

发布于 2017-02-08 06:32:53

尝试创建所需的功能并设置

代码语言:javascript
运行
复制
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42102598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档