Any idea of how can I include Selenium on a AEM project?

83 Views Asked by At

NoSuchMethodError com.google.common.collect.ImmutableMap when trying to create an instance of a Chrome driver on a AEM Maven archetype project.

So I'm trying to use Selenium on a AEM Maven archetype project but doing just a simple test I'm getting an error when I try to instantiate my driver object.

I had include these dependencies on my pom.xml (plus the dependencies that comes with the default project)

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.9.1</version>
</dependency>

<dependency>
  <groupId>io.github.bonigarcia</groupId>
  <artifactId>webdrivermanager</artifactId>
  <version>5.3.3</version>
  <scope>test</scope>
</dependency>

So my test is a very simple test, I'm creating a chrome driver with webdrivermanager, then initializing it and open www.google.com in Chrome.

//...*imports used on this partial code*
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;

public void test() {
   WebDriver driver = WebDriverManager.chromedriver().create();
   driver = new ChromeDriver();
   driver.get("https://www.google.com");
}

When I run that test I'm getting this NoSuchMethodError ImmutableMap java.lang.NoSuchMethodError: com.google.common.collect.ImmutableMap.of(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableMap;

I read that there was an old error with this about the version of guava dependency, but I'm using selenium version 4.9.1 which includes com.google.guava:guava:31.0.1-jre

Any help on this will be very appreciated. Thanks in advance.

0

There are 0 best solutions below