- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 Selenium 测试的新手。在使用网站时,我收到一个错误: "main"java.lang.NoClassDefFoundError: org/apache/http/ssl/SSLContexts
你能帮我解决这个问题吗?
这是我的示例代码
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());
}
}
控制台输出
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
已添加依赖项:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.3.3</version>
</dependency>
最佳答案
出现此问题的原因是 SSLContext 已被重新定位到 httpClient >= 4.4 中的另一个包。因此,我们需要将 httpCore 依赖项升级到 4.4 或任何新版本。
关于java - SSLContext 的 Selenium NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42102598/
我正在尝试在 GWT Jetty 开发模式下执行以下代码 final SSLContext sslContext = SSLContext.getInstance(PROTOCOL);
如何将 javax.net.ssl.SSLContext 转换为 io.netty.handler.ssl.SslContext ?我可以访问 SSLContext,但需要在我的客户端库中设置 SSl
我正在开发一个应用程序,它是一个独立的应用程序,并将其打包为 jar 文件(类似于 OSGi 插件),并将该 jar 部署到 JBoss 。 当我在 Eclipse 中运行应用程序时,应用程序工作正常
我在以下远程服务器设置上使用 Python 3.6.5: Server: Windows 10 Python: 3.6.5 Requests: 2.18.4 Pentaho: 8.0 当我在服务器命令
我试图弄清楚如何使用 Request 指定 SSLContext。 我有两个功能理论上应该做同样的事情,但是带有 Requests 的那个不起作用。 def func_OK(token): c
我有以下简单的类(class): 导入 javax.net.ssl.SSLContext; public class AClass { public void someMethod() thr
我有以下简单的类(class): 导入 javax.net.ssl.SSLContext; public class AClass { public void someMethod() thr
请帮助了解如何向 SSL 上下文提供证书链。 简介:我正在使用 EWSJavaAPI 1.2 连接到 ms Exchange。它使用带有双向身份验证的 TLS 连接,基于我自己的公司颁发的证书,该证书
基于 Jcs ( HttpUnit WebConversation SSL Issues ) 的回答,我尝试用我自己的信任管理器替换 SSLContext.getDefault()。 SSLConte
我见过很多构造一个将接受所有服务器证书的 SSLContext 的例子。对于我的测试用例,我试图做完全相反的事情并强制客户端拒绝服务器的证书。 所以我正在尝试创建一个不包含根证书的 KeyStore
我正在尝试创建自己的 HTTPS 服务器,并且有两个代码片段: 第一个: private SSLContext createSSLContext() throws KeyStoreException,
在测试我的客户端-服务器分布式系统时,一开始我很惊讶地发现 TLS 的默认 JSSE 实现不进行主机名验证。我在 this 中尝试了接受的答案问题,但我的用例有点不同。我使用 RabbitMQ 的连接
我使用 OpenSSL 库在 Ruby 中编写了以下代码,该库从 cloudflare.com 获取证书链。但是 Cloudflare 有一个混合系统,旧浏览器接收 RSA 证书,新客户端接收 ECD
整个代码比较复杂,直接进入正题。代码如下 SSLContext ctx = SSLContext.getInstance("TLS"); 如果您阅读 docs对于它说的 getInstance(Str
当我尝试使用 getServerSocket 方法初始化 SSLServerSocket 时,如下所示,并定义了 keystore : public static ServerSocket getSe
我像这样使用 Java 6 (SunJSSE) 中的默认 JSSE 提供程序, SSLContext sslCtx = SSLContext.getInstance("TLS"); 我可以从多个线程安
我正在以标准方式创建 SSLContext: 获取.p12证书文件, 创建 keystore 并将证书加载到其中, 创建 KeyManagerFactory,使用 KeyStore 初始化它,并获取
如果我使用以下代码是因为我想更改证书的验证方式。 trm = 一些信任经理 SSLContext sc = SSLContext.getInstance("SSL"); sc.init(null, n
我的问题的基本组成部分是(上下文跟随代码片段) 以下代码是否是通过 -Djavax.net.ssl.keystore 设置默认 Java keystore 的有效替代方法? 除了更改默认 key 和信
我们接到电话SSLContext.getInstance("TLS")报告为漏洞。推荐的修复方法是使用 SSLContext.getInstance("TLSv1.2") . 我了解到自 2021 年
我是一名优秀的程序员,十分优秀!