javaseleniumhtmlunit-driver

org.openqa.selenium.WebDriverException: Browser failed to start, test in fluentlium


I want to run simple example in fluentlium but I get an exception in driver

My code:

Config.java

public  class Config extends ConfigurationDefaults {
    @Override
 public String getWebDriver() {
   System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
   WebDriver driver = new ChromeDriver();
   driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
   return "chrome";
 }
}

AbstractBaseTest.java

@FluentConfiguration(configurationDefaults =fluentleniumTutorial.Config.class)
public class AbstractBaseTest extends FluentTest {}

TestExample.java

public class TestExample extends AbstractBaseTest{
     @Test
        public void testGoogle() {
           goTo("http://www.google.com");
        }
}

My exception:

> org.openqa.selenium.WebDriverException: Browser failed to start, test [ testGoogle(fluentleniumTutorial.TestExample) ] execution interrupted.
Caused by: [ com.gargoylesoftware.htmlunit.WebWindowListener]
Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T14:04:26.12Z'
System info: host: 'DEV09', ip: '10.167.166.143', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_191'
Driver info: driver.version: unknown
    at org.fluentlenium.adapter.FluentTestRunnerAdapter.starting(FluentTestRunnerAdapter.java:116)
    at org.fluentlenium.adapter.junit.FluentTest.access$000(FluentTest.java:15)
    at org.fluentlenium.adapter.junit.FluentTest$1.starting(FluentTest.java:25)
    at org.fluentlenium.adapter.junit.FluentTestRule$1.evaluate(FluentTestRule.java:43)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.fluentlenium.adapter.junit.FluentTest$2$1.evaluate(FluentTest.java:55)
    at org.junit.rules.RunRules.evaluate(RunRules.java:20)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError
    at java.util.concurrent.FutureTask.report(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.fluentlenium.adapter.FluentTestRunnerAdapter.getSharedWebDriver(FluentTestRunnerAdapter.java:181)
    at org.fluentlenium.adapter.FluentTestRunnerAdapter.getSharedWebDriver(FluentTestRunnerAdapter.java:142)
    at org.fluentlenium.adapter.FluentTestRunnerAdapter.starting(FluentTestRunnerAdapter.java:109)
    ... 21 more
Caused by: java.lang.ExceptionInInitializerError
    at org.fluentlenium.adapter.FluentAdapter.newWebDriver(FluentAdapter.java:146)
    at org.fluentlenium.adapter.SharedWebDriverContainer$Impl.createDriver(SharedWebDriverContainer.java:92)
    at org.fluentlenium.adapter.SharedWebDriverContainer$Impl.getOrCreateDriver(SharedWebDriverContainer.java:83)
    at org.fluentlenium.adapter.SharedWebDriverContainer.getOrCreateDriver(SharedWebDriverContainer.java:28)
    at org.fluentlenium.adapter.FluentTestRunnerAdapter.lambda$getSharedWebDriver$0(FluentTestRunnerAdapter.java:172)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.fluentlenium.configuration.ConfigurationException: class org.fluentlenium.configuration.DefaultWebDriverFactories$HtmlUnitWebDriverFactory can't be instantiated.
    at org.fluentlenium.configuration.AbstractFactoryRegistryImpl.<init>(AbstractFactoryRegistryImpl.java:57)
    at org.fluentlenium.configuration.WebDriversRegistryImpl.<init>(WebDriversRegistryImpl.java:16)
    at org.fluentlenium.configuration.WebDrivers.<init>(WebDrivers.java:17)
    at org.fluentlenium.configuration.WebDrivers.<clinit>(WebDrivers.java:15)
    ... 9 more
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.fluentlenium.configuration.AbstractFactoryRegistryImpl.<init>(AbstractFactoryRegistryImpl.java:53)
    ... 12 more
Caused by: java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/WebWindowListener
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.fluentlenium.configuration.ReflectiveWebDriverFactory.<init>(ReflectiveWebDriverFactory.java:35)
    at org.fluentlenium.configuration.DefaultWebDriverFactories$HtmlUnitWebDriverFactory.<init>(DefaultWebDriverFactories.java:113)
    ... 17 more
Caused by: java.lang.ClassNotFoundException: com.gargoylesoftware.htmlunit.WebWindowListener
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 21 more

Solution

  • See you bottom line exception, ClassNotFoundException: com.gargoylesoftware.htmlunit.WebWindowListener

    It's a part of HtmlUnit classes that you need to download and add to your project classpath (lib folder)

    See Selenium-WebDriver’s Drivers:

    HtmlUnit Driver This is currently the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. HtmlUnit is a java based implementation of a WebBrowser without a GUI. For any language binding (other than java) the Selenium Server is required to use this driver.