4
respostas

java.lang.NoClassDefFoundError: org/openqa/selenium/HasAuthentication

Não estou conseguindo rodar o projeto. É apresentado este erro: java.lang.NoClassDefFoundError: org/openqa/selenium/HasAuthentication

A minha máquina tem o S.O. Windows 10

Segue o código da classe HelloWorldSelenium:

package br.com.alura.leilao;

import org.junit.jupiter.api.Test; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;

public class HelloWorldSelenium {

@Test
public void helloTest() {
    System.setProperty("webdriver.chrome.driver", "drivers/chromedriver.exe");
    WebDriver browser = new ChromeDriver();
    browser.navigate().to("http://localhost:8080/leiloes");
}

}

E o pom.xml:

4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.1.RELEASE br.com.alura leilao 0.0.1-SNAPSHOT leilao

<properties>
    <maven.compiler.version>3.8.1</maven.compiler.version>
    <maven.surefire.version>2.22.1</maven.surefire.version>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity5</artifactId>
    </dependency>

    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-java8time</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>4.1.2</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <encoding>UTF-8</encoding>
                <source>${java.version}</source>
                <target>${java.version}</target>
            </configuration>
        </plugin>
    </plugins>
</build>

4 respostas

colocou todas as dependencias?

Acredito que sim. As dependências estão no pom.xml que eu postei anteriormente.

Tentou apagar a linha referente a tag version nas dependências do POM, Jamesson?

Oi Jamesson,

Posta um print aqui do seu projeto no Eclipse, pois pode ser algum problema do MAven ao baixar alguma das dependências.