Hot answers tagged

2

According to WebDriver API JavaDoc, if no matching elements are found then the NoSuchElementException is thrown by findElement() method, not NullPointerException. So the root cause of your problem is not a wrong XPath expression. Instead, your stacktrace and your source code suggests this is a problem with driver variable not initialized: you try to call ...


1

I used a helper function to see if at least one element still exists. Because I'm finding a new element each loop, StaleElementException doesn't occur anymore. while(isElementVisible(d, (By.ClassName("search-choice-close")))) { d.FindElement(By.ClassName("search-choice-close")).Click(); ...


1

I'd recommend you to use any of the below wait methods. You may find success with any of these 3 methods, but it is always a good practice to use Explicit Wait as you are instructing the web driver to specifically look for what you need, instead of blindly waiting till the entire DOM gets loaded. Explicit Wait: (Most Preferred) WebDriverWait wait = new ...



Only top voted, non community-wiki answers of a minimum length are eligible