2017-02-08 7 views
1

セレンのテストは初めてです。私は1つのエラーを取得していますウェブサイトでの作業中:"メイン" java.lang.NoClassDefFoundErrorが:ORG/apacheの/ HTTP/SSL/SSLContextsSSLContextのSelenium NoClassDefFoundError

あなたはこれで私を助けてくださいことはできますか?ここで

は私のサンプルコードは

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> 

答えて

2

このI ssueは、SSLContextがhttpClient> = 4.4の別のパッケージに再配置されたために発生します。したがって、httpCoreの依存関係を4.4または新しいバージョンにアップグレードする必要があります。

+0

回答を受け入れることをお勧めします。 –

+0

はい私の答えを受け入れるのに7時間かかります –

-2

試行は、所望の機能を作成し、

capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS、TRUE)に設定します。