0

I am trying to automate simple web application, for that, I am using Page Object Model Pattern, with Selenium and Java, My maven pom dependencies look like this:

<dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>3.12.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.14.0</version>
    </dependency>

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.13.5</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-ie-driver</artifactId>
        <version>3.0.0-beta4</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.12.0</version>
    </dependency>

</dependencies>

My Page Object Class looks like this:

public class Page {
    public Page(WebDriver driver) {
        PageFactory.initElements(driver, this);
    }
    @FindBy(linkText = "Players")
    private WebElement playersLink;

    public boolean isPlayersLinkVisible(){
        return playersLink.isDisplayed();
    }
}

My test looks like this:

public class Test{
  @Test
  public void test(){
        WebDriver driver = new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get(URL);
        Page page = new Page(driver);
        System.out.println(page.isPlayersLinkVisible());
  }
}

But I am getting this exception, and can't figure out why?

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

at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.proxyForLocator(DefaultFieldDecorator.java:101)
at org.openqa.selenium.support.pagefactory.DefaultFieldDecorator.decorate(DefaultFieldDecorator.java:62)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:113)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:105)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:92)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:79)

2 Answers 2

1

I had this issue because the selenium support version was different than the other selenium libraries I was using. The issue is fixed when the same version is used for all selenium libraries including the selenium support library in pom.xml

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for your help. I had the same issue and resolved by upgrading old libraries in classpath.
0

I figured that out, apparently there were incompatible dependencies, I removed unnecessary ones and left only the ones I need:

<dependencies>

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

    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.9.13.5</version>
    </dependency>

    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

</dependencies>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.