Actually I'm trying to run the test cases for a web application in Eclipse using TestNG. But i'm having some problem while running the Selenium Scripts. I just want to continue the execution even though some test cases fails. But i don't know how to do that.
I'm very new to this topic friends. Please Help me..!!! Anyway Thanks in Advance.
Using the alwaysRun = true annotation in TestNG is not going to entirely solve your problem.
In order to allow Selenium to continue even when there is an occasional Exception, you need to define a Wait object with the FluentWait class, like so:
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring( NoSuchElementException.class, ElementNotFoundException.class );
// using a customized expected condition
WebElement foo1 = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply( WebDriver driver ) {
// do something here if you want
return driver.findElement( By.id("foo") );
}
});
// using a built-in expected condition
WebElement foo2 = wait.until( ExpectedConditions.visibilityOfElementLocated(
By.id("foo") );
This gives you the ability to ignore exceptions whenever .findElement is called until a certain pre-configured timeout is reached.