0

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

3
  • 1
    I think its able to find the element, just that the element it finds is not clickable as you try. Thats what the logs read. Commented Sep 11, 2017 at 5:53
  • Can you please share your site url? Commented Sep 11, 2017 at 6:01
  • 1
    The url is demo.vizru.com Commented Sep 11, 2017 at 6:41

1 Answer 1

2

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"

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

3 Comments

yes .. now it seems to be working thank you . i have one more doubt .. can i declare webdriver wait time common in all testcases . how can i use ( WebDriverWait wait = new WebDriverWait(driver, 25);) this method in parent class so all child class class can have acces . am new to java
Nice answer @imBollaveni
@JithinEzio declare wait and driver as static variables in the parent class. so that you can use them in all your child classes. Ex: static WebDriver driver; static WebDriverWait wait;

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.