Posts Tagged ‘annotations’

Selenium Web driver tests fail if run all together

If you write unit tests that must be run like if you had to open/refresh a new browser session each time, you can use a method with before annotations:

public void refreshPage() {

If all tests are individually successful (green) but fail all together, the reason might also been that you need to wait for some resources to be available on the page, so you also need to handle it, setting the timeout like this:

 public WebElement getSaveButton() {
     return findDynamicElementByXPath(By.xpath("//*[@id=\"form:btnSave\"]"), 320);

320 is a long time, but you must make sure that you give enough time to get all that it takes to test.