From ebaf1214d6214f6a7ecacd9ee997653a8b6b1279 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Mon, 28 Aug 2023 12:02:22 +0200 Subject: [PATCH] [grid] Detect Safari and SFT only when on macOS. Helps with #12521 --- .../selenium/safari/SafariDriverInfo.java | 18 +++++++++++----- .../safari/SafariTechPreviewDriverInfo.java | 21 +++++++++++++------ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/java/src/org/openqa/selenium/safari/SafariDriverInfo.java b/java/src/org/openqa/selenium/safari/SafariDriverInfo.java index a3f9f34f10a78..325f65252940b 100644 --- a/java/src/org/openqa/selenium/safari/SafariDriverInfo.java +++ b/java/src/org/openqa/selenium/safari/SafariDriverInfo.java @@ -24,6 +24,7 @@ import java.util.Optional; import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; +import org.openqa.selenium.Platform; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; @@ -65,8 +66,12 @@ public boolean isSupportingBiDi() { @Override public boolean isAvailable() { try { - DriverFinder.getPath(SafariDriverService.createDefaultService(), getCanonicalCapabilities()); - return true; + if (Platform.getCurrent().is(Platform.MAC)) { + DriverFinder.getPath( + SafariDriverService.createDefaultService(), getCanonicalCapabilities()); + return true; + } + return false; } catch (IllegalStateException | WebDriverException e) { return false; } @@ -75,9 +80,12 @@ public boolean isAvailable() { @Override public boolean isPresent() { try { - DriverFinder.getPath( - SafariDriverService.createDefaultService(), getCanonicalCapabilities(), true); - return true; + if (Platform.getCurrent().is(Platform.MAC)) { + DriverFinder.getPath( + SafariDriverService.createDefaultService(), getCanonicalCapabilities(), true); + return true; + } + return false; } catch (IllegalStateException | WebDriverException e) { return false; } diff --git a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverInfo.java b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverInfo.java index 1a5ea414357fe..baf36bcccf639 100644 --- a/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverInfo.java +++ b/java/src/org/openqa/selenium/safari/SafariTechPreviewDriverInfo.java @@ -24,6 +24,7 @@ import java.util.Optional; import org.openqa.selenium.Capabilities; import org.openqa.selenium.ImmutableCapabilities; +import org.openqa.selenium.Platform; import org.openqa.selenium.SessionNotCreatedException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; @@ -66,9 +67,12 @@ public boolean isSupportingBiDi() { @Override public boolean isAvailable() { try { - DriverFinder.getPath( - SafariTechPreviewDriverService.createDefaultService(), getCanonicalCapabilities()); - return true; + if (Platform.getCurrent().is(Platform.MAC)) { + DriverFinder.getPath( + SafariTechPreviewDriverService.createDefaultService(), getCanonicalCapabilities()); + return true; + } + return false; } catch (IllegalStateException | WebDriverException e) { return false; } @@ -77,9 +81,14 @@ public boolean isAvailable() { @Override public boolean isPresent() { try { - DriverFinder.getPath( - SafariTechPreviewDriverService.createDefaultService(), getCanonicalCapabilities(), true); - return true; + if (Platform.getCurrent().is(Platform.MAC)) { + DriverFinder.getPath( + SafariTechPreviewDriverService.createDefaultService(), + getCanonicalCapabilities(), + true); + return true; + } + return false; } catch (IllegalStateException | WebDriverException e) { return false; }