Hot answers tagged

1

When you return back to the page, page reloads and all elements become stale. For you it may look like same element (with same locator), but page is new object. So you need to fetch the elements again.


1

On the Scorex_LoginTestCases (Btw, we do not use underscore in names in Java (See conventions), the objects objLogin and objHome are not initialized. On the TestBase, you should initialize them using the PageFactory's method initElements. You can see a sample here.


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(); TestHelper....


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