NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until

I am trying to run the below selenium code:

        WebDriver driver;
        System.setProperty("webdriver.chrome.driver", "C:\\Driver\\chromedriver.exe");
        driver = new ChromeDriver();
        driver.get("http://www.behsad.com/nportal/Default.aspx?tabid=55");

        driver.findElement(By.id("dnn_dnnUser_enhancedRegisterLink")).click();

        WebDriverWait wait=new WebDriverWait(driver, 30);
        WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(
                                        By.id("dnn_dnnUser_enhancedRegisterLink")));
        element.click();

      

here is my pom.xml:

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-picocontainer</artifactId>
    <version>1.2.5</version>
</dependency>

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

      

and at the end there is a code import:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

      

the code gets stuck at the line:

WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(
                                            By.id("dnn_dnnUser_enhancedRegisterLink")));

      

and he complains:

java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.WebDriverWait.until(Lcom/google/common/base/Function;)Ljava/lang/Object;

      

+3


source to share


3 answers


Selenium 3.1.0 requires guava 21 for the wait.until method. Try adding this to your pom, preferably closer to the beginning if another dependency is being imported and an earlier version of guava:



<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>21.0</version>
</dependency>

      

0


source


I think your problem is this line of code

WebElement element=wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("dnn_dnnUser_enhancedRegisterLink")));

      

How is Wait.until used to tell your web driver to wait for a certain action to occur, which is the visibility Element located at ID = "dnn_dnnUser_enhancedRegisterLink" in your case but this method does not return a web element object, so you cannot use it to define a web element



Instead, you just need to write:

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("dnn_dnnUser_enhancedRegisterLink")));

      

0


source


Worked with the latest banks:

Appium 1.8.1
Java-client 5.0.4
Selenium-java 3.7.1

      

0


source







All Articles