简体   繁体   中英

Selenium webdriver wait, Element not clickable exception

i am using selenium webdriver for chrome. I am testing an web application with lot of ajax contents so after login into the application it will take some seconds to load ajax content in home page.

I've used explicit wait after login to wait until finding the element. But it fails mostly. I've given 25 seconds to wait but it fails after 4 seconds of wait . The error is ,...

Unknown error: Element <a href="/ls/create_new" class="ajax addDashButton hasLink">...</a> is not clickable at point (144, 223). 

Other element would receive the click: (Session info: chrome=60.0.3112.78) (

My code is ..

public class login {
    WebDriver driver;

  @Test
  public void f() {

      System.setProperty("webdriver.chrome.driver", "filepath/chromedriver");
      driver = new ChromeDriver();
  driver.get("URL");
  driver.manage().window().maximize();

      driver.findElement(By.name("username")).sendKeys("username");
      driver.findElement(By.name("password")).sendKeys("password");
      driver.findElement(By.className("login")).click();

      WebDriverWait wait = new WebDriverWait(driver, 25);

      wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText("Create New App")));
      driver.findElement(By.linkText("Create New App")).click();
  }
}

This is just part of my code ..What is the correct way to use webdriver wait. TY

Intead of using presenceOfElementLocated , try once visibilityOfElementLocated .

  • visibilityOfElementLocated: it checks for element should be visible and present.
  • presenceOfElementLocated: It just checks for element is present in the DOM or not.

for more information use can check the below link- What is the exact difference between "ExpectedConditions.visibilityOfElementLocated" and "ExpectedConditions.presenceOfElementLocated"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM