diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java index 0436a59d..46b0ac6a 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java @@ -117,6 +117,10 @@ public static String guessBrowserVersion(String browserName) { return getIEVersion(); } else if (browserName.equalsIgnoreCase("internet explorer")) { return getIEVersion(); + } else if (browserName.equalsIgnoreCase("Edge")) { + return getEdgeVersion(); + } else if (browserName.equalsIgnoreCase("MicrosoftEdge")) { + return getEdgeVersion(); } else { return ""; } @@ -236,4 +240,34 @@ private static String getChromeVersion() { } return version; } + + /** + * + * @return version of Edge installed + */ + private static String getEdgeVersion() { + String version =""; + try { + /************ First Method ****************/ +// String[] cmd = new String[7]; +// cmd[0] = "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe "; +// cmd[1] = "Get-AppxPackage"; +// cmd[2] = "Microsoft.MicrosoftEdge"; +// cmd[3] = "|"; +// cmd[4] = "Format-Wide"; +// cmd[5] = "-Property"; +// cmd[6] = "Version"; + + /************ Second Method ****************/ + String cmd = "C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe (Get-AppxPackage Microsoft.MicrosoftEdge).Version"; + JsonObject object = ExecuteCommand.execRuntime(cmd, true); + logger.info("Detected Edge version: " + object.get("out").getAsJsonArray().get(0).getAsString().trim().replaceAll("[^\\d.]", "")); + version = object.get("out").getAsJsonArray().get(0).getAsString().trim().replaceAll("[^\\d.]", ""); + } catch (Exception e) { + // If ExecuteCommand.execRuntime fails, still return ""; + logger.warn(e.getMessage()); + } + return version; + } + }