Skip to content

Commit 3fe4cf7

Browse files
committed
Deflake tests on Chrome for Android by working around https://code.google.com/p/chromedriver/issues/detail?id=1044
1 parent 0ae8a97 commit 3fe4cf7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: java/client/test/org/openqa/selenium/WindowSwitchingTest.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.junit.Assert.assertThat;
2525
import static org.junit.Assert.fail;
2626
import static org.junit.Assume.assumeFalse;
27+
import static org.openqa.selenium.Platform.ANDROID;
2728
import static org.openqa.selenium.WaitingConditions.newWindowIsOpened;
2829
import static org.openqa.selenium.WaitingConditions.windowHandleCountToBe;
2930
import static org.openqa.selenium.WaitingConditions.windowHandleCountToBeGreaterThan;
@@ -199,6 +200,7 @@ public void testShouldBeAbleToIterateOverAllOpenWindows() {
199200
@Test
200201
@Ignore(MARIONETTE)
201202
public void testClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToHang() {
203+
throws Exception {
202204
assumeFalse(Browser.detect() == Browser.opera &&
203205
TestUtilities.getEffectivePlatform().is(Platform.WINDOWS));
204206

@@ -214,6 +216,10 @@ public void testClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToH
214216

215217
driver.switchTo().window("result");
216218

219+
// TODO Remove sleep when https://code.google.com/p/chromedriver/issues/detail?id=1044 is fixed.
220+
if (TestUtilities.isChrome(driver) && TestUtilities.getEffectivePlatform(driver).is(ANDROID)) {
221+
Thread.sleep(1000);
222+
}
217223
try {
218224
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("close")));
219225
driver.findElement(By.id("close")).click();
@@ -233,7 +239,7 @@ public void testClickingOnAButtonThatClosesAnOpenWindowDoesNotCauseTheBrowserToH
233239
@JavascriptEnabled
234240
@Test
235241
@Ignore(MARIONETTE)
236-
public void testCanCallGetWindowHandlesAfterClosingAWindow() {
242+
public void testCanCallGetWindowHandlesAfterClosingAWindow() throws Exception {
237243
assumeFalse(Browser.detect() == Browser.opera &&
238244
TestUtilities.getEffectivePlatform().is(Platform.WINDOWS));
239245

@@ -251,6 +257,10 @@ public void testCanCallGetWindowHandlesAfterClosingAWindow() {
251257
driver.switchTo().window("result");
252258
int allWindowHandles = driver.getWindowHandles().size();
253259

260+
// TODO Remove sleep when https://code.google.com/p/chromedriver/issues/detail?id=1044 is fixed.
261+
if (TestUtilities.isChrome(driver) && TestUtilities.getEffectivePlatform(driver).is(ANDROID)) {
262+
Thread.sleep(1000);
263+
}
254264
try {
255265
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("close"))).click();
256266

0 commit comments

Comments
 (0)