Skip to content

Commit

Permalink
fix tests that should assume ScriptTimeoutException now, attempt to d…
Browse files Browse the repository at this point in the history
…eflake other tests
  • Loading branch information
lukeis committed Oct 3, 2016
1 parent 87f0371 commit 92cf774
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void shouldTimeoutIfScriptDoesNotInvokeCallback() {
// Script is expected to be async and explicitly callback, so this should timeout.
executor.executeAsyncScript("return 1 + 2;");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
} catch (ScriptTimeoutException exception) {
// Do nothing.
}
}
Expand All @@ -181,7 +181,7 @@ public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithAZeroTimeout() {
try {
executor.executeAsyncScript("window.setTimeout(function() {}, 0);");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
} catch (ScriptTimeoutException exception) {
// Do nothing.
}
}
Expand All @@ -207,7 +207,7 @@ public void shouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout() {
"var callback = arguments[arguments.length - 1];" +
"window.setTimeout(callback, 1500);");
fail("Should have thrown a TimeOutException!");
} catch (TimeoutException exception) {
} catch (ScriptTimeoutException exception) {
// Do nothing.
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.Color;
import org.openqa.selenium.support.Colors;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;
Expand Down Expand Up @@ -226,7 +227,8 @@ public void testSelectionSelectByWord() {
WebElement keyReporter = driver.findElement(By.id("keyReporter"));

getBuilder(driver).click(keyReporter).sendKeys("abc def").perform();
assertThat(keyReporter.getAttribute("value"), is("abc def"));
wait.until(
ExpectedConditions.attributeToBe(keyReporter, "value", "abc def"));

getBuilder(driver).click(keyReporter)
.keyDown(Keys.SHIFT)
Expand All @@ -237,7 +239,8 @@ public void testSelectionSelectByWord() {
.sendKeys(Keys.DELETE)
.perform();

assertThat(keyReporter.getAttribute("value"), is("abc "));
wait.until(
ExpectedConditions.attributeToBe(keyReporter, "value", "abc "));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.testing.NeedsFreshDriver;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.Point;
Expand Down Expand Up @@ -481,8 +482,8 @@ public void testMoveMouseByOffsetOverAndOutOfAnElement() {
new Actions(driver).moveToElement(greenbox, 2, 2)
.moveByOffset(shiftX, shiftY)
.moveByOffset(-shiftX, -shiftY).perform();
assertEquals(
Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

wait.until(ExpectedConditions.attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba()));
}

@JavascriptEnabled
Expand Down Expand Up @@ -511,8 +512,8 @@ public void testCanMoveOverAndOutOfAnElement() {
// would be happy with 1.
new Actions(driver).moveToElement(redbox, size.getWidth() + 2, size.getHeight() + 2)
.perform();
assertEquals(
Colors.GREEN.getColorValue(), Color.fromString(redbox.getCssValue("background-color")));

wait.until(ExpectedConditions.attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba()));
}

private boolean fuzzyPositionMatching(int expectedX, int expectedY, String locationTouple) {
Expand Down

0 comments on commit 92cf774

Please sign in to comment.