pelican
pelican

Reputation: 6224

Serenity BDD - Caused by: java.lang.ClassNotFoundException: com.google.common.base.Optional

I'm new to the Serenity Bdd framework; I cloned this repo: https://github.com/serenity-bdd/serenity-screenplay-train-demo

Os: Ubuntu: 17.04 
Intellij IDEA Community 2017.3 
Pom.xml: https://github.com/serenity-bdd/serenity-screenplay-train-demo/blob/master/pom.xml

<dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-core</artifactId>
            <version>${serenity.version}</version>
        </dependency>
        <dependency>
            <groupId>net.serenity-bdd</groupId>
            <artifactId>serenity-screenplay</artifactId>
            <version>${serenity.version}</version>
        </dependency>

And I'm trying to run the automated tests but run into the error:

net.thucydides.core.webdriver.UnsupportedDriverException: 
Could not instantiate class org.openqa.selenium.chrome.ChromeDriver
.
.
.
Caused by: net.thucydides.core.webdriver.UnsupportedDriverException: Could 
not instantiate new WebDriver instance of type class 
org.openqa.selenium.chrome.ChromeDriver (The path to the chromedriver driver 
executable must be set by the webdriver.chrome.driver system property; for 
more information, see 
https://sites.google.com/a/chromium.org/chromedriver/downloads. The latest 
version can be downloaded from 
https://sites.google.com/a/chromium.org/chromedriver/downloads
.
.
.
.
Caused by: java.lang.IllegalStateException: The path to the chromedriver 
driver executable must be set by the webdriver.chrome.driver system 
property; for more information, see 
https://sites.google.com/a/chromium.org/chromedriver/downloads. The latest 
version can be downloaded from 
https://sites.google.com/a/chromium.org/chromedriver/downloads

I know I'm missing some jars or libraries but not sure how to add them or what to add. I am guessing I should be updating the maven pom.xml to add the missing dependencies?

UPDATES:

Turns out the pom.xml was pointing to older library versions, so I updated them and now getting this new error:

ERROR n.t.core.webdriver.WebDriverFacade - FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE class org.openqa.selenium.chrome.ChromeDriver: Could not instantiate new WebDriver instance of type class org.openqa.selenium.chrome.ChromeDriver (The path to the chromedriver driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://sites.google.com/a/chromium.org/chromedriver/downloads. The latest version can be downloaded from https://sites.google.com/a/chromium.org/chromedriver/downloads

Upvotes: 0

Views: 5091

Answers (1)

John Smart
John Smart

Reputation: 942

The message "FAILED TO CREATE NEW WEBDRIVER_DRIVER INSTANCE" means that Selenium could not connect to WebDriver. The rest of the message ("The path to the chromedriver driver executable must be set by the webdriver.chrome.driver system property...") explains what you need to do. You need to download the latest chromedriver executable and place it on your system path. Serenity will set the webdriver.chrome.driver property for you - do not, repeat do not, hard code this path in your test classes or your properties file (hard-coding the chromedriver path is a commonly seen but horribly wrong anti-pattern, as it makes your tests extremely unportable).

Upvotes: 1

Related Questions