1

I am waiting for WebElement is clickable using below code:

WebDriverWait wait = new WebDriverWait(driver,9);
WebElement element = wait.until(ExpectedConditions.visibilityOf(CancelListingButton));

But I see the error for using ExpectedConditions in eclipse as

ExpectedConditions cannot be resolved to a variable

I am using selenium 3.0 as maven project and included the import statement:

import org.openqa.selenium.support.ui.ExpectedConditions;

Is there any other dependency to use ExpectedConditions?

pom.xml dependencies included:

<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>

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

<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>2.0a7</version>    

Mainly the issue is even after including the import statement:

import org.openqa.selenium.support.ui.ExpectedConditions;  

I still cannot use ExpectedConditions anywhere in my code as it gives me error to create a class ExpectedConditions and it cannot be resolved to variable.

3
  • You probably have a scope problem. Could you provide more information about this code? I'm suspecting about this CancelListingButton. Maybe you need this.CancelListingButton; but I can't say for sure with only these two lines. stackoverflow.com/questions/13116940/… Commented Jan 23, 2017 at 16:24
  • Since you included maven as a tag. It's probably safe to say that theres some contextual information with your maven build. Can you show us relevant portions of your pom.xml, your dependencies in particular?
    – Julian
    Commented Jan 23, 2017 at 19:31
  • I caught the issue, it was with wrong version for selenium-support dependency. Thanks for leading me this answer Commented Jan 24, 2017 at 7:34

3 Answers 3

1

The issue arises from wrong version of selenium-support, defined in pom.xml.

Just wanted to point out that selenium-java already contains a reference to selenium-support, thus no separate dependency declaration is needed for selenium-support as the correct version will be used by Maven automatically.

0

As now a days most of the most of the software testing companies are using Maven for the execution of the selenium frameworks. We need to take care of the dependencies that we are using along with their versions. The issue can be resolved by simply updating the pom file. Instead of using

org.seleniumhq.selenium selenium-java 3.0.1 org.seleniumhq.selenium selenium-support 2.0a7

You can update to the pretty latest version.

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

Now right click on your Project. Maven>Update Project issue is resolved.

-1
(CancelListingButton)); 

Should be a variable. You should make it as:

String CancelListingButton = "xpath of your element"; 

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.