2

[i'm seeing the issue with Selenium remote driver when I'm executing the script with Htmlunit driver. Note 1:- Same script works without any issue when I'm running with Firefox driver.] Note 2: My browser had security authentication process for whatever the site i open, Not sure if that have ant role in this.

I have observed the selenium remote driver under maven shows with little different icon in left pane. I feel its jar file loading issue. I tried to put the selenium remote driver manually into .m2 repository. 1

Error message:-

Exception in thread "main" java.lang.NoClassDefFoundError: org/openqa/selenium/remote/SessionNotFoundException
    at TestPackage.titleNUrlCheckingTest.main(titleNUrlCheckingTest.java:16)
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.remote.SessionNotFoundException
    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)
... 1 more

[enter image description here][2]

Rajesh Varma
  • 151
  • 2
  • 10

2 Answers2

3

You need to use latest version, note the change of artifactId from old versions.

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>htmlunit-driver</artifactId>
    <version>2.26</version>
</dependency>

which depends on

selenium-api 3.3.1

Update:

Your pom.xml works with simple test case of HtmlUnitDriver, but there is a potential conflict of versions, you should exclude HtmlUnitDriver 2.24 from selenium-java 3.3.1:

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.3.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.seleniumhq.selenium</groupId>
                <artifactId>htmlunit-driver</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

Also, try to remove all selenium dependencies, and have only htmlunit-driver, all needed dependencies are automatically handled by maven.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
2

Please update your POM XML file with latest version of htmlunit dependency

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>htmlunit-driver</artifactId>
  <version>2.32.1</version>
</dependency>

and remove if you have something like

<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-htmlunit-driver</artifactId>
    <version>2.52.0</version>
</dependency> 

and update project. This should resolve your exception issue.

Reference: https://github.com/SeleniumHQ/selenium/issues/4930

Pang
  • 9,564
  • 146
  • 81
  • 122