Reputation: 468
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.
Upvotes: 2
Views: 3770
Reputation: 29689
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.
Upvotes: 2
Reputation: 3235
Ok, in that case you need to use one of the attribute of @Test
Annotation i.e
@Test(alwaysRun = true)
If set to true, this test method will always be run even if it depends on a method that failed.
Upvotes: 2