Skip to content

Commit

Permalink
Java tests: Don't attempt to "recover from sauce error" if it's just …
Browse files Browse the repository at this point in the history
…an assumption exception that contains "sauce" word in the message
  • Loading branch information
barancev committed Jan 30, 2016
1 parent 835190d commit 169b2a3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.google.common.base.Throwables;

import org.junit.AssumptionViolatedException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.rules.RuleChain;
Expand Down Expand Up @@ -112,9 +113,7 @@ protected void starting(Description description) {
removeDriver();
}
try {
driver = actuallyCreateDriver();
wait = new WebDriverWait(driver, 30);
shortWait = new WebDriverWait(driver, 5);
createDriver();
} catch (Exception e) {
throw new RuntimeException("Exception creating driver", e);
}
Expand Down Expand Up @@ -159,11 +158,11 @@ public void evaluate() throws Throwable {
}

private void dealWithSauceFailureIfNecessary(Throwable t) {
if (t.getMessage() != null
if (!(t instanceof AssumptionViolatedException) && t.getMessage() != null
&& (t.getMessage().contains("sauce") || t.getMessage().contains("Sauce"))) {
removeDriver();
try {
actuallyCreateDriver();
createDriver();
} catch (Exception e) {
throw new RuntimeException("Exception creating driver, after Sauce-detected exception", e);
}
Expand Down Expand Up @@ -267,6 +266,12 @@ public WebDriver getWrappedDriver() {
return storedDriver.get();
}

private void createDriver() {
driver = actuallyCreateDriver();
wait = new WebDriverWait(driver, 30);
shortWait = new WebDriverWait(driver, 5);
}

public static WebDriver actuallyCreateDriver() {
WebDriver driver = storedDriver.get();

Expand Down

0 comments on commit 169b2a3

Please sign in to comment.