| diff --git a/java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java b/java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java |
| index 9790472265..47c0ff4e62 100644 |
| --- a/java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java |
| +++ b/java/client/src/org/openqa/selenium/chrome/ChromeDriverService.java |
| @@ -206,6 +206,7 @@ protected File findDefaultExecutable() { |
| if (whitelistedIps != null) { |
| argsBuilder.add(String.format("--whitelisted-ips=%s", whitelistedIps)); |
| } |
| + argsBuilder.add("--readable-timestamp"); |
| |
| return argsBuilder.build(); |
| } |
| diff --git a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java |
| index 38592c9405..3c96b41e0e 100644 |
| --- a/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java |
| +++ b/java/client/src/org/openqa/selenium/chrome/ChromeOptions.java |
| @@ -21,6 +21,7 @@ |
| import org.openqa.selenium.chromium.ChromiumOptions; |
| import org.openqa.selenium.remote.BrowserType; |
| import org.openqa.selenium.remote.CapabilityType; |
| +import static com.google.common.base.Preconditions.checkNotNull; |
| |
| /** |
| * Class to manage options specific to {@link ChromeDriver}. |
| @@ -49,9 +50,39 @@ |
| * object. |
| */ |
| public static final String CAPABILITY = "goog:chromeOptions"; |
| + private String androidPackage; |
| + private String androidActivity; |
| + private String androidProcess; |
| |
| public ChromeOptions() { |
| super(CapabilityType.BROWSER_NAME, BrowserType.CHROME, CAPABILITY); |
| } |
| |
| + /** |
| + * Sets the Android package name for Chrome or a WebView app. The package should already exist |
| + * on the Android device. |
| + * |
| + * @param package_name Package name for Chrome or a WebView app |
| + */ |
| + public void setAndroidPackage(String package_name) { |
| + androidPackage = checkNotNull(package_name); |
| + } |
| + |
| + /** |
| + * Sets the name of the Activity hosting the WebView under test. |
| + * |
| + * @param package_name Android Activity class name |
| + */ |
| + public void setAndroidActivity(String activity_name) { |
| + androidActivity = checkNotNull(activity_name); |
| + } |
| + |
| + /** |
| + * Sets the process name for the Activity hosting the WebView under test. |
| + * |
| + * @param package_name Android process name |
| + */ |
| + public void setAndroidProcess(String process_name) { |
| + androidProcess = checkNotNull(process_name); |
| + } |
| } |
| diff --git a/java/client/src/org/openqa/selenium/net/PortProber.java b/java/client/src/org/openqa/selenium/net/PortProber.java |
| index 3aee1e5c70..758898b2e1 100644 |
| --- a/java/client/src/org/openqa/selenium/net/PortProber.java |
| +++ b/java/client/src/org/openqa/selenium/net/PortProber.java |
| @@ -49,7 +49,7 @@ |
| } |
| |
| public static final int HIGHEST_PORT = 65535; |
| - public static final int START_OF_USER_PORTS = 1024; |
| + public static final int START_OF_USER_PORTS = 6700; |
| |
| private PortProber() { |
| // Utility class |
| diff --git a/java/client/test/org/openqa/selenium/CookieImplementationTest.java b/java/client/test/org/openqa/selenium/CookieImplementationTest.java |
| index b6a883708f..89d1b8700a 100644 |
| --- a/java/client/test/org/openqa/selenium/CookieImplementationTest.java |
| +++ b/java/client/test/org/openqa/selenium/CookieImplementationTest.java |
| @@ -386,6 +386,7 @@ public void canHandleSecureCookie() { |
| |
| Cookie retrieved = driver.manage().getCookieNamed("fish"); |
| assertThat(retrieved).isNotNull(); |
| + driver.manage().deleteAllCookies(); |
| } |
| |
| @Test |
| diff --git a/java/client/test/org/openqa/selenium/WindowTest.java b/java/client/test/org/openqa/selenium/WindowTest.java |
| index 574a794d52..06fb8bce1f 100644 |
| --- a/java/client/test/org/openqa/selenium/WindowTest.java |
| +++ b/java/client/test/org/openqa/selenium/WindowTest.java |
| @@ -107,7 +107,7 @@ public void testSetsThePositionOfTheCurrentWindow() { |
| // off-screen. Therefore, try to stay on-screen. Hopefully you have more than 210 px, |
| // or this may fail. |
| window.setSize(new Dimension(200, 200)); |
| - Point targetPosition = new Point(position.x + 10, position.y + 10); |
| + Point targetPosition = new Point(position.x + 30, position.y + 30); |
| window.setPosition(targetPosition); |
| |
| wait.until($ -> window.getPosition().x == targetPosition.x); |
| @@ -125,7 +125,7 @@ public void testCanMaximizeTheWindow() { |
| // though others aren't defined in org.openqa.selenium.Platform). |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| - changeSizeTo(new Dimension(640, 323)); |
| + changeSizeTo(new Dimension(640, 398)); |
| enlargeBy(WebDriver.Window::maximize); |
| } |
| |
| @@ -139,7 +139,7 @@ public void testCanMaximizeTheWindowFromFrame() { |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| driver.get(pages.framesetPage); |
| - changeSizeTo(new Dimension(640, 324)); |
| + changeSizeTo(new Dimension(640, 399)); |
| |
| driver.switchTo().frame("fourth"); |
| enlargeBy(WebDriver.Window::maximize); |
| @@ -155,7 +155,7 @@ public void testCanMaximizeTheWindowFromIframe() { |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| driver.get(pages.iframePage); |
| - changeSizeTo(new Dimension(640, 325)); |
| + changeSizeTo(new Dimension(640, 400)); |
| |
| driver.switchTo().frame("iframe1-name"); |
| enlargeBy(WebDriver.Window::maximize); |
| @@ -170,8 +170,9 @@ public void canFullscreenTheWindow() { |
| // though others aren't defined in org.openqa.selenium.Platform). |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| - changeSizeTo(new Dimension(640, 323)); |
| + changeSizeTo(new Dimension(640, 398)); |
| enlargeBy(WebDriver.Window::fullscreen); |
| + changeSizeTo(new Dimension(640, 398)); |
| } |
| |
| @SwitchToTopAfterTest |
| @@ -185,10 +186,11 @@ public void canFullscreenTheWindowFromFrame() { |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| driver.get(pages.framesetPage); |
| - changeSizeTo(new Dimension(640, 324)); |
| + changeSizeTo(new Dimension(640, 399)); |
| |
| driver.switchTo().frame("fourth"); |
| enlargeBy(WebDriver.Window::fullscreen); |
| + changeSizeTo(new Dimension(640, 399)); |
| } |
| |
| @SwitchToTopAfterTest |
| @@ -202,10 +204,11 @@ public void canFullscreenTheWindowFromIframe() { |
| assumeFalse(TestUtilities.getEffectivePlatform(driver).is(ANDROID)); |
| |
| driver.get(pages.iframePage); |
| - changeSizeTo(new Dimension(640, 325)); |
| + changeSizeTo(new Dimension(640, 400)); |
| |
| driver.switchTo().frame("iframe1-name"); |
| enlargeBy(WebDriver.Window::fullscreen); |
| + changeSizeTo(new Dimension(640, 400)); |
| } |
| |
| private void changeSizeBy(int deltaX, int deltaY) { |
| diff --git a/java/client/test/org/openqa/selenium/chrome/ChromeOptionsFunctionalTest.java b/java/client/test/org/openqa/selenium/chrome/ChromeOptionsFunctionalTest.java |
| index 232718f92b..3df6752a3a 100644 |
| --- a/java/client/test/org/openqa/selenium/chrome/ChromeOptionsFunctionalTest.java |
| +++ b/java/client/test/org/openqa/selenium/chrome/ChromeOptionsFunctionalTest.java |
| @@ -52,6 +52,7 @@ public void tearDown() { |
| public void canStartChromeWithCustomOptions() { |
| ChromeOptions options = new ChromeOptions(); |
| options.addArguments("user-agent=foo;bar"); |
| + setWebDriverChromeBinary(options); |
| driver = new ChromeDriver(options); |
| |
| driver.get(pages.clickJacker); |
| @@ -74,6 +75,7 @@ public void optionsStayEqualAfterSerialization() { |
| public void canSetAcceptInsecureCerts() { |
| ChromeOptions options = new ChromeOptions(); |
| options.setAcceptInsecureCerts(true); |
| + setWebDriverChromeBinary(options); |
| driver = new ChromeDriver(options); |
| |
| assertThat(driver.getCapabilities().getCapability(ACCEPT_SSL_CERTS)).isEqualTo(true); |
| @@ -84,6 +86,7 @@ public void canSetAcceptInsecureCerts() { |
| public void canAddExtensionFromFile() { |
| ChromeOptions options = new ChromeOptions(); |
| options.addExtensions(InProject.locate(EXT_PATH).toFile()); |
| + setWebDriverChromeBinary(options); |
| driver = new ChromeDriver(options); |
| |
| driver.get(pages.clicksPage); |
| @@ -101,6 +104,7 @@ public void canAddExtensionFromStringEncodedInBase64() throws IOException { |
| ChromeOptions options = new ChromeOptions(); |
| options.addEncodedExtensions(Base64.getEncoder().encodeToString( |
| Files.readAllBytes(InProject.locate(EXT_PATH)))); |
| + setWebDriverChromeBinary(options); |
| driver = new ChromeDriver(options); |
| |
| driver.get(pages.clicksPage); |
| @@ -112,4 +116,10 @@ public void canAddExtensionFromStringEncodedInBase64() throws IOException { |
| new WebDriverWait(driver, 10).until(titleIs("clicks")); |
| } |
| |
| + private void setWebDriverChromeBinary(ChromeOptions options) { |
| + String chromePath = System.getProperty("webdriver.chrome.binary"); |
| + if (chromePath != null) { |
| + options.setBinary(chromePath); |
| + } |
| + } |
| } |
| diff --git a/java/client/test/org/openqa/selenium/devtools/DevToolsTestBase.java b/java/client/test/org/openqa/selenium/devtools/DevToolsTestBase.java |
| index a1f7ce8d6f..9cb884785b 100644 |
| --- a/java/client/test/org/openqa/selenium/devtools/DevToolsTestBase.java |
| +++ b/java/client/test/org/openqa/selenium/devtools/DevToolsTestBase.java |
| @@ -23,9 +23,10 @@ |
| import org.openqa.selenium.environment.TestEnvironment; |
| import org.openqa.selenium.environment.webserver.AppServer; |
| import org.openqa.selenium.testing.Pages; |
| +import org.openqa.selenium.testing.JUnit4TestBase; |
| |
| |
| -public abstract class DevToolsTestBase { |
| +public abstract class DevToolsTestBase extends JUnit4TestBase { |
| |
| DevTools devTools; |
| protected TestEnvironment environment; |
| diff --git a/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java b/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java |
| index 4d943e35e6..affeaaf838 100644 |
| --- a/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java |
| +++ b/java/client/test/org/openqa/selenium/environment/webserver/JettyAppServer.java |
| @@ -117,10 +117,6 @@ public JettyAppServer(String hostName, int httpPort, int httpsPort) { |
| ServletContextHandler defaultContext = addResourceHandler( |
| DEFAULT_CONTEXT_PATH, webSrc); |
| |
| - addJsResourceHandler(JS_SRC_CONTEXT_PATH, "javascript"); |
| - addJsResourceHandler(CLOSURE_CONTEXT_PATH, "third_party/closure/goog"); |
| - addJsResourceHandler(THIRD_PARTY_JS_CONTEXT_PATH, "third_party/js"); |
| - |
| TemporaryFilesystem tempFs = TemporaryFilesystem.getDefaultTmpFS(); |
| tempPageDir = tempFs.createTempDir("pages", "test"); |
| addResourceHandler(TEMP_SRC_CONTEXT_PATH, tempPageDir.toPath()); |
| diff --git a/java/client/test/org/openqa/selenium/interactions/BasicKeyboardInterfaceTest.java b/java/client/test/org/openqa/selenium/interactions/BasicKeyboardInterfaceTest.java |
| index f79ae7d559..db33271998 100644 |
| --- a/java/client/test/org/openqa/selenium/interactions/BasicKeyboardInterfaceTest.java |
| +++ b/java/client/test/org/openqa/selenium/interactions/BasicKeyboardInterfaceTest.java |
| @@ -231,6 +231,8 @@ public void testSelectionSelectBySymbol() { |
| |
| shortWait.until(ExpectedConditions.attributeToBe(input, "value", "abc def")); |
| |
| + ((Interactive)driver).resetInputState(); |
| + |
| getBuilder(driver).click(input) |
| .keyDown(Keys.SHIFT) |
| .sendKeys(Keys.LEFT) |
| @@ -257,6 +259,8 @@ public void testSelectionSelectByWord() { |
| getBuilder(driver).click(input).sendKeys("abc def").perform(); |
| wait.until(ExpectedConditions.attributeToBe(input, "value", "abc def")); |
| |
| + ((Interactive)driver).resetInputState(); |
| + |
| getBuilder(driver).click(input) |
| .keyDown(Keys.SHIFT) |
| .keyDown(Keys.CONTROL) |
| diff --git a/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java b/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java |
| index 76d3028af6..55152f77dd 100644 |
| --- a/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java |
| +++ b/java/client/test/org/openqa/selenium/interactions/BasicMouseInterfaceTest.java |
| @@ -376,7 +376,7 @@ public void testMovingMouseToRelativeElementOffset() { |
| driver.get(pages.mouseTrackerPage); |
| |
| WebElement trackerDiv = driver.findElement(By.id("mousetracker")); |
| - new Actions(driver).moveToElement(trackerDiv, 95, 195).perform(); |
| + new Actions(driver).moveToElement(trackerDiv, 45, -5).perform(); |
| |
| WebElement reporter = driver.findElement(By.id("status")); |
| |
| @@ -392,7 +392,7 @@ public void testMovingMouseToRelativeZeroElementOffset() { |
| driver.get(pages.mouseTrackerPage); |
| |
| WebElement trackerDiv = driver.findElement(By.id("mousetracker")); |
| - new Actions(driver).moveToElement(trackerDiv, 0, 0).perform(); |
| + new Actions(driver).moveToElement(trackerDiv, -50, -200).perform(); |
| |
| WebElement reporter = driver.findElement(By.id("status")); |
| |
| @@ -433,15 +433,16 @@ public void testMoveMouseByOffsetOverAndOutOfAnElement() { |
| int shiftX = redboxPosition.getX() - greenboxPosition.getX(); |
| int shiftY = redboxPosition.getY() - greenboxPosition.getY(); |
| |
| - new Actions(driver).moveToElement(greenbox, 2, 2).perform(); |
| + Dimension greenBoxSize = greenbox.getSize(); |
| |
| + new Actions(driver).moveToElement(greenbox, 2 - greenBoxSize.getWidth()/2, 2 - greenBoxSize.getHeight()/2).perform(); |
| shortWait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba())); |
| |
| - new Actions(driver).moveToElement(greenbox, 2, 2) |
| + new Actions(driver).moveToElement(greenbox, 2 - greenBoxSize.getWidth()/2, 2 - greenBoxSize.getHeight()/2) |
| .moveByOffset(shiftX, shiftY).perform(); |
| shortWait.until(attributeToBe(redbox, "background-color", Colors.RED.getColorValue().asRgba())); |
| |
| - new Actions(driver).moveToElement(greenbox, 2, 2) |
| + new Actions(driver).moveToElement(greenbox, 2 - greenBoxSize.getWidth()/2, 2 - greenBoxSize.getHeight()/2) |
| .moveByOffset(shiftX, shiftY) |
| .moveByOffset(-shiftX, -shiftY).perform(); |
| |
| @@ -459,8 +460,9 @@ public void testCanMoveOverAndOutOfAnElement() { |
| WebElement greenbox = driver.findElement(By.id("greenbox")); |
| WebElement redbox = driver.findElement(By.id("redbox")); |
| Dimension size = redbox.getSize(); |
| + Dimension greenBoxSize = greenbox.getSize(); |
| |
| - new Actions(driver).moveToElement(greenbox, 1, 1).perform(); |
| + new Actions(driver).moveToElement(greenbox, 1- greenBoxSize.getWidth()/2, 1- greenBoxSize.getHeight()/2).perform(); |
| |
| assertThat(Color.fromString(redbox.getCssValue("background-color"))) |
| .isEqualTo(GREEN.getColorValue()); |
| @@ -471,7 +473,7 @@ public void testCanMoveOverAndOutOfAnElement() { |
| |
| // IE8 (and *only* IE8) requires a move of 2 pixels. All other browsers |
| // would be happy with 1. |
| - new Actions(driver).moveToElement(redbox, size.getWidth() + 2, size.getHeight() + 2) |
| + new Actions(driver).moveToElement(redbox, size.getWidth()/2 + 2, size.getHeight()/2 + 2) |
| .perform(); |
| |
| wait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba())); |
| diff --git a/java/client/test/org/openqa/selenium/interactions/CombinedInputActionsTest.java b/java/client/test/org/openqa/selenium/interactions/CombinedInputActionsTest.java |
| index db1bdb6a73..ec2e2a0bb4 100644 |
| --- a/java/client/test/org/openqa/selenium/interactions/CombinedInputActionsTest.java |
| +++ b/java/client/test/org/openqa/selenium/interactions/CombinedInputActionsTest.java |
| @@ -46,6 +46,7 @@ |
| import org.openqa.selenium.testing.JUnit4TestBase; |
| import org.openqa.selenium.testing.NotYetImplemented; |
| import org.openqa.selenium.testing.SwitchToTopAfterTest; |
| +import org.openqa.selenium.Dimension; |
| |
| import java.util.List; |
| |
| @@ -226,10 +227,11 @@ public void testClickAfterMoveToAnElementWithAnOffsetShouldUseLastMousePosition( |
| driver.get(pages.clickEventPage); |
| |
| WebElement element = driver.findElement(By.id("eventish")); |
| + Dimension elementSize = element.getSize(); |
| Point location = element.getLocation(); |
| |
| new Actions(driver) |
| - .moveToElement(element, 20, 10) |
| + .moveToElement(element, 20 - elementSize.getWidth()/2, 10 - elementSize.getHeight()/2) |
| .click() |
| .perform(); |
| |
| diff --git a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| index 4399da0d42..9ffb660ebc 100644 |
| --- a/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| +++ b/java/client/test/org/openqa/selenium/testing/JUnit4TestBase.java |
| @@ -30,6 +30,7 @@ |
| import org.junit.runners.model.Statement; |
| import org.openqa.selenium.Capabilities; |
| import org.openqa.selenium.WebDriver; |
| +import org.openqa.selenium.WebDriverException; |
| import org.openqa.selenium.environment.GlobalTestEnvironment; |
| import org.openqa.selenium.environment.InProcessTestEnvironment; |
| import org.openqa.selenium.environment.TestEnvironment; |
| @@ -163,10 +164,25 @@ private boolean notImplemented(Stream<NotYetImplemented> nyi) { |
| return nyi.anyMatch(driver -> matches(current, new Browser[]{driver.value()})); |
| } |
| |
| + private boolean isReadyToRun(Description description) { |
| + String name = description.getTestClass().getSimpleName() + "." + description.getMethodName(); |
| + String readyToRunFilter = System.getProperty("readyToRun"); |
| + if (readyToRunFilter != null) { |
| + String[] readyToRunTests = readyToRunFilter.split(":"); |
| + for (int i = 0; i < readyToRunTests.length; i++) { |
| + if (name.matches(readyToRunTests[i])) { |
| + return true; |
| + } |
| + } |
| + } |
| + return false; |
| + } |
| + |
| @Override |
| public Statement apply(final Statement base, final Description description) { |
| - if (notImplemented(description.getAnnotation(NotYetImplementedList.class)) || |
| - notImplemented(description.getAnnotation(NotYetImplemented.class))) { |
| + if ((notImplemented(description.getAnnotation(NotYetImplementedList.class)) || |
| + notImplemented(description.getAnnotation(NotYetImplemented.class))) |
| + && !isReadyToRun(description)) { |
| return new Statement() { |
| @Override |
| public void evaluate() throws Throwable { |
| @@ -209,10 +225,32 @@ public void createNewDriver(Capabilities capabilities) { |
| |
| private static WebDriver actuallyCreateDriver() { |
| WebDriver driver = storedDriver.get(); |
| + // If the driver is left in a bad state, create a new one. |
| + // This happens on Android after any test that creates its own driver. |
| + // Since only one instance of Chrome can run on Android at a time, the |
| + // stored driver's browser is destroyed. |
| + try |
| + { |
| + if (driver != null) |
| + { |
| + driver.getCurrentUrl(); |
| + } |
| + } |
| + catch (WebDriverException e) |
| + { |
| + try |
| + { |
| + driver.quit(); |
| + } |
| + catch (RuntimeException ignored) |
| + { |
| + System.exit(1); |
| + } |
| + driver = null; |
| + } |
| |
| if (driver == null || |
| (driver instanceof RemoteWebDriver && ((RemoteWebDriver)driver).getSessionId() == null)) { |
| - StaticResources.ensureAvailable(); |
| driver = new WebDriverBuilder().get(); |
| storedDriver.set(driver); |
| } |
| @@ -221,6 +259,29 @@ private static WebDriver actuallyCreateDriver() { |
| |
| private static WebDriver actuallyCreateDriver(Capabilities capabilities) { |
| WebDriver driver = storedDriver.get(); |
| + // If the driver is left in a bad state, create a new one. |
| + // This happens on Android after any test that creates its own driver. |
| + // Since only one instance of Chrome can run on Android at a time, the |
| + // stored driver's browser is destroyed. |
| + try |
| + { |
| + if (driver != null) |
| + { |
| + driver.getCurrentUrl(); |
| + } |
| + } |
| + catch (WebDriverException e) |
| + { |
| + try |
| + { |
| + driver.quit(); |
| + } |
| + catch (RuntimeException ignored) |
| + { |
| + System.exit(1); |
| + } |
| + driver = null; |
| + } |
| |
| if (driver == null || |
| (driver instanceof RemoteWebDriver && ((RemoteWebDriver)driver).getSessionId() == null)) { |
| diff --git a/java/client/test/org/openqa/selenium/testing/TestIgnorance.java b/java/client/test/org/openqa/selenium/testing/TestIgnorance.java |
| index 0912d363a6..3465bfbe50 100644 |
| --- a/java/client/test/org/openqa/selenium/testing/TestIgnorance.java |
| +++ b/java/client/test/org/openqa/selenium/testing/TestIgnorance.java |
| @@ -63,20 +63,44 @@ public TestIgnorance(Browser driver) { |
| } |
| |
| public boolean isIgnored(Description method) { |
| - boolean ignored = ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(IgnoreList.class)) || |
| - ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(Ignore.class)) || |
| - ignoreComparator.shouldIgnore(method.getAnnotation(IgnoreList.class)) || |
| - ignoreComparator.shouldIgnore(method.getAnnotation(Ignore.class)); |
| - |
| - ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getTestClass().getAnnotation(org.junit.Ignore.class)); |
| - ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getAnnotation(org.junit.Ignore.class)); |
| - if (Boolean.getBoolean("ignored_only")) { |
| - ignored = !ignored; |
| + |
| + String name = method.getTestClass().getSimpleName() + "." + method.getMethodName(); |
| + String filter = System.getProperty("filter", ".*"); |
| + String[] patternGroups = filter.split("-"); |
| + String[] positivePatterns = patternGroups[0].split(":"); |
| + String[] negativePatterns = new String[0]; |
| + |
| + if (patternGroups.length > 1) { |
| + negativePatterns = patternGroups[1].split(":"); |
| + |
| + for (int i = 0; i < negativePatterns.length; i++) { |
| + if (name.matches(negativePatterns[i])) { |
| + return true; |
| + } |
| + } |
| } |
| |
| - ignored |= isIgnoredDueToEnvironmentVariables(method); |
| + for (int i = 0; i < positivePatterns.length; i++) { |
| + if (name.matches(positivePatterns[i])) { |
| + |
| + boolean ignored = ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(IgnoreList.class)) || |
| + ignoreComparator.shouldIgnore(method.getTestClass().getAnnotation(Ignore.class)) || |
| + ignoreComparator.shouldIgnore(method.getAnnotation(IgnoreList.class)) || |
| + ignoreComparator.shouldIgnore(method.getAnnotation(Ignore.class)); |
| |
| - return ignored; |
| + ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getTestClass().getAnnotation(org.junit.Ignore.class)); |
| + ignored |= isIgnoredBecauseOfJUnit4Ignore(method.getAnnotation(org.junit.Ignore.class)); |
| + |
| + if (Boolean.getBoolean("ignored_only")) { |
| + ignored = !ignored; |
| + } |
| + |
| + ignored |= isIgnoredDueToEnvironmentVariables(method); |
| + |
| + return ignored; |
| + } |
| + } |
| + return true; |
| } |
| |
| private boolean isIgnoredBecauseOfJUnit4Ignore(org.junit.Ignore annotation) { |
| diff --git a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java |
| index 6177c2a4bc..8b10ff727f 100644 |
| --- a/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java |
| +++ b/java/client/test/org/openqa/selenium/testing/drivers/TestChromeDriver.java |
| @@ -61,13 +61,11 @@ public TestChromeDriver(Capabilities capabilities) { |
| private static URL getServiceUrl() { |
| try { |
| if (service == null) { |
| - Path logFile = Files.createTempFile("chromedriver", ".log"); |
| service = new ChromeDriverService.Builder() |
| .withVerbose(true) |
| - .withLogFile(logFile.toFile()) |
| .build(); |
| - LOG.info("chromedriver will log to " + logFile); |
| service.start(); |
| + System.clearProperty("webdriver.chrome.logfile"); |
| // Fugly. |
| Runtime.getRuntime().addShutdownHook(new Thread(() -> service.stop())); |
| } |
| @@ -80,15 +78,39 @@ private static URL getServiceUrl() { |
| private static Capabilities chromeWithCustomCapabilities(Capabilities originalCapabilities) { |
| ChromeOptions options = new ChromeOptions(); |
| options.addArguments("disable-extensions", "disable-infobars", "disable-breakpad"); |
| - Map<String, Object> prefs = new HashMap<>(); |
| - prefs.put("exit_type", "None"); |
| - prefs.put("exited_cleanly", true); |
| - options.setExperimentalOption("prefs", prefs); |
| + String androidPackage = System.getProperty("webdriver.chrome.android_package"); |
| + |
| + if (androidPackage == null) { |
| + Map<String, Object> prefs = new HashMap<>(); |
| + prefs.put("exit_type", "None"); |
| + prefs.put("exited_cleanly", true); |
| + options.setExperimentalOption("prefs", prefs); |
| + } |
| + |
| String chromePath = System.getProperty("webdriver.chrome.binary"); |
| if (chromePath != null) { |
| options.setBinary(new File(chromePath)); |
| } |
| |
| + if (androidPackage != null) { |
| + options.setExperimentalOption("androidPackage", androidPackage); |
| + options.setAndroidPackage(androidPackage); |
| + } |
| + |
| + String androidActivity = System.getProperty("webdriver.chrome.android_activity"); |
| + |
| + if (androidActivity != null) { |
| + options.setExperimentalOption("androidActivity", androidActivity); |
| + options.setAndroidActivity(androidActivity); |
| + } |
| + |
| + String androidProcess = System.getProperty("webdriver.chrome.android_process"); |
| + |
| + if (androidProcess != null) { |
| + options.setExperimentalOption("androidProcess", androidProcess); |
| + options.setAndroidProcess(androidProcess); |
| + } |
| + |
| if (originalCapabilities != null) { |
| options.merge(originalCapabilities); |
| } |
| diff --git a/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java b/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java |
| index 98eaf6a13c..6e3bf6676a 100644 |
| --- a/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java |
| +++ b/java/client/test/org/openqa/selenium/testing/drivers/WebDriverBuilder.java |
| @@ -49,8 +49,12 @@ |
| private static LinkedList<Runnable> shutdownActions = new LinkedList<>(); |
| private static Set<WebDriver> managedDrivers = new HashSet<>(); |
| static { |
| - shutdownActions.add(() -> managedDrivers.forEach(WebDriver::quit)); |
| - Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdownActions.forEach(Runnable::run))); |
| + Runtime.getRuntime().addShutdownHook(new Thread( () -> { |
| + try { |
| + managedDrivers.forEach(WebDriver::quit); |
| + } catch (Exception a ) { |
| + } |
| + })); |
| } |
| |
| static void addShutdownAction(Runnable action) { |