How to eleiminate Selenium NoClassDefFoundError for SSLContext

0 votes

I started learning selenium last week. While tying to open browser using selenium it shows "main" java.lang.NoClassDefFoundError: org/apache/http/ssl/SSLContexts

Can anybody help me in this?

My code

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());

     }

}

Output

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)

    

Dependencies

<dependency>

        <groupId>org.apache.httpcomponents</groupId>

        <artifactId>httpcore</artifactId>

        <version>4.3.3</version>

    </dependency>

May 4, 2018 in Selenium by Martin
• 4,320 points
3,229 views

1 answer to this question.

0 votes
You need to upgrade the httpCore dependency to 4.4 or any new version. SSLContext has been relocated to another package in httpClient >= 4.4.
answered May 4, 2018 by Samarpit
• 5,910 points

Related Questions In Selenium

0 votes
1 answer

How to pause for few seconds in Selenium?

you can locate an element that loads ...READ MORE

answered Jul 6, 2018 in Selenium by Meci Matt
• 9,460 points
7,441 views
0 votes
1 answer

How to wait for the webpage to load in selenium using java

Firstly, when you launch a web application, ...READ MORE

answered Aug 29, 2018 in Selenium by bug_seeker
• 15,510 points
1,939 views
+2 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,688 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,150 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,230 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,881 views
0 votes
1 answer

How to get next sibling element using XPath and Selenium for Java?

Below code will help you: Try following-sibling axis : WebElement ...READ MORE

answered May 15, 2018 in Selenium by Samarpit
• 5,910 points
20,820 views
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,910 points
2,762 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP