Skip to content

Commit

Permalink
Support Microsoft Edge Chromium
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpijnacker-philips committed Jun 18, 2021
1 parent 88a3f4d commit 8179334
Show file tree
Hide file tree
Showing 22 changed files with 1,073 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Config {
public static final String EDGEDRIVER = "edgedriver";
public static final String CHROME_DRIVER = "chromedriver";
public static final String GECKO_DRIVER = "geckodriver";
public static final String MSEDGE_DRIVER = "msedgedriver";
public static final String SHARED_DIR = "expose_directory";

public static final String AUTO_START_NODE = "auto_start_node";
Expand Down Expand Up @@ -140,6 +141,7 @@ private void initialize() {
initializeIEDriver();
initializeChromeDriver();
initializeGeckoDriver();
initializeMsEdgeDriver();

getConfigMap().put(NODE_CONFIG_FILES, new LinkedList<String>());
getConfigMap().put(HUB_CONFIG_FILES, new LinkedList<String>());
Expand Down Expand Up @@ -215,6 +217,10 @@ private void initializeGeckoDriver() {
getConfigMap().put(GECKO_DRIVER, new GeckoDriver());
}

private void initializeMsEdgeDriver() {
getConfigMap().put(MSEDGE_DRIVER, new MsEdgeDriver());
}

public void addNodeConfigFile(String filename) {
LinkedList<String> files = (LinkedList<String>) getConfigMap().get(NODE_CONFIG_FILES);
files.add(filename);
Expand Down Expand Up @@ -246,6 +252,7 @@ public static Config initilizedFromUserInput() {
config.initializeIEDriver();
config.initializeChromeDriver();
config.initializeGeckoDriver();
config.initializeMsEdgeDriver();

return FirstTimeRunConfig.customiseConfig(config);
}
Expand Down Expand Up @@ -337,6 +344,23 @@ public DriverInfo getGeckoDriver() {
}
}

public DriverInfo getMsEdgeDriver() {
try {
return (MsEdgeDriver) getConfigMap().get(MSEDGE_DRIVER);
} catch (ClassCastException e) {
LinkedTreeMap
stringMapFromGoogleWhoCantUseHashMapOnNestedObjects =
(LinkedTreeMap) getConfigMap().get(MSEDGE_DRIVER);
DriverInfo msEdgeDriver = new MsEdgeDriver();

msEdgeDriver.putAll(stringMapFromGoogleWhoCantUseHashMapOnNestedObjects);

getConfigMap().put(MSEDGE_DRIVER, msEdgeDriver);

return msEdgeDriver;
}
}

public DriverInfo getEdgeDriver() {
try {
EdgeDriver driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class DefaultConfig {
private static final String ieDriverDefaultVersion = "2.53.1";
private static final String chromeDriverDefaultVersion = "2.22";
private static final String geckoDriverDefaultVersion = "0.10.0";
private static final String msEdgeDriverDefaultVersion = "75.0.139.20";

public static Config getDefaultConfig() {
config = new Config();
Expand All @@ -101,6 +102,7 @@ public static Config getDefaultConfig() {
loadIEDriverInfo();
loadChromeDriverInfo();
loadGeckoDriverInfo();
loadMsEdgeDriverInfo();
loadDisabledPlugins();
loadEnabledPlugins();
loadSetupConfig();
Expand Down Expand Up @@ -208,6 +210,10 @@ public static String getGeckoDriverDefaultVersion() {
return geckoDriverDefaultVersion;
}

public static String getMsEdgeDriverDefaultVersion() {
return msEdgeDriverDefaultVersion;
}

private static void loadSetupConfig() {
config.addSetupTask(MoveMouse.class.getCanonicalName());
}
Expand Down Expand Up @@ -256,6 +262,16 @@ private static void loadGeckoDriverInfo() {
config.getGeckoDriver().setVersion(getGeckoDriverDefaultVersion());
}

private static void loadMsEdgeDriverInfo() {
String tmpDir;

tmpDir = config.getWebdriver().getDirectory() + RuntimeConfig.getOS().getFileSeparator();

config.getMsEdgeDriver().setDirectory(tmpDir + "msedgedriver");
config.getMsEdgeDriver().setVersion(getMsEdgeDriverDefaultVersion());
config.getMsEdgeDriver().setBit(JsonCodec.WebDriver.Downloader.BIT_32);
}

private static void loadLogConfig() {
config.setLogMaximumSize(LOG_MAXIMUM_SIZE);
config.setLogMaximumAge(LOG_MAX_AGE);
Expand All @@ -279,6 +295,7 @@ private static void loadEnabledPlugins() {
config.addActivatedModules(KillAllFirefox.class.getCanonicalName());
config.addActivatedModules(KillAllChrome.class.getCanonicalName());
config.addActivatedModules(KillAllSafari.class.getCanonicalName());
config.addActivatedModules(KillAllMsEdge.class.getCanonicalName());

config.addActivatedModules(SetAutoLogonUser.class.getCanonicalName());
config.addActivatedModules(GetProcesses.class.getCanonicalName());
Expand All @@ -305,6 +322,7 @@ private static void loadEnabledPlugins() {
config.addActivatedModules(DownloadIEDriver.class.getCanonicalName());
config.addActivatedModules(DownloadChromeDriver.class.getCanonicalName());
config.addActivatedModules(DownloadGeckoDriver.class.getCanonicalName());
config.addActivatedModules(DownloadMsEdgeDriver.class.getCanonicalName());
config.addActivatedModules(SessionHistory.class.getCanonicalName());

config.addActivatedModules(UpgradeGridExtrasTask.class.getCanonicalName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.groupon.seleniumgridextras.config.remote.ConfigPusher;
import com.groupon.seleniumgridextras.downloader.ChromeDriverDownloader;
import com.groupon.seleniumgridextras.downloader.GeckoDriverDownloader;
import com.groupon.seleniumgridextras.downloader.MsEdgeDriverDownloader;
import com.groupon.seleniumgridextras.downloader.webdriverreleasemanager.WebDriverReleaseManager;
import com.groupon.seleniumgridextras.os.GridPlatform;
import com.groupon.seleniumgridextras.tasks.SetAutoLogonUser;
Expand Down Expand Up @@ -279,6 +280,7 @@ private static void setDriverAutoUpdater(Config defaultConfig) {
WebDriverReleaseManager manager = RuntimeConfig.getReleaseManager();
String versionOfChrome = manager.getChromeDriverLatestVersion().getPrettyPrintVersion(".");
String versionOfGecko = manager.getGeckoDriverLatestVersion().getPrettyPrintVersion(".");
String versionOfMsEdge = manager.getMsEdgeDriverLatestVersion().getPrettyPrintVersion(".");
String versionOfWebDriver = manager.getWedriverLatestVersion().getPrettyPrintVersion(".");
String versionOfIEDriver = manager.getIeDriverLatestVersion().getPrettyPrintVersion(".");

Expand All @@ -298,9 +300,12 @@ private static void setDriverAutoUpdater(Config defaultConfig) {
askQuestion("What version of Gecko Driver should we use?", versionOfGecko);
versionOfChrome =
askQuestion("What version of Chrome Driver should we use?", versionOfChrome);
versionOfMsEdge =
askQuestion("What version of MsEdge Driver should we use?", versionOfMsEdge);
}
defaultConfig.getChromeDriver().setVersion(versionOfChrome);
defaultConfig.getGeckoDriver().setVersion(versionOfGecko);
defaultConfig.getMsEdgeDriver().setVersion(versionOfMsEdge);

if(gridExtrasVersion.startsWith("1.")) {
if(VersionCompare.versionCompare(versionOfWebDriver, "3.7.1") >= 0) {
Expand Down Expand Up @@ -347,9 +352,21 @@ private static void setDriverAutoUpdater(Config defaultConfig) {
}
defaultConfig.getGeckoDriver().setBit(bitOfGeckoDriver);

String bitOfMsEdgeDriver = JsonCodec.WebDriver.Downloader.BIT_32;
String[] bitVersionsMsEdgeDriver = MsEdgeDriverDownloader.getBitArchitecturesForVersion(versionOfMsEdge);
if (bitVersionsMsEdgeDriver.length > 1) {
bitOfMsEdgeDriver = askQuestion("What bit of MsEdgeDriver should we use (" + StringUtils.join(bitVersionsMsEdgeDriver, ", ") + ")?", JsonCodec.WebDriver.Downloader.BIT_32);
} else if (bitVersionsMsEdgeDriver.length == 1) {
bitOfMsEdgeDriver = bitVersionsMsEdgeDriver[0];
} else {
System.out.println("\nWARNING: We were unable to find the correct bit of MsEdgeDriver for this OS and MsEdgeDriver version: " + versionOfMsEdge + " so will default to '32' please update this to be more accurate, or grid may not function properly\n");
}
defaultConfig.getMsEdgeDriver().setBit(bitOfMsEdgeDriver);

System.out.println("Current Selenium Driver Version: " + defaultConfig.getWebdriver().getVersion());
System.out.printf("Current Chrome Driver Version: %s (%s bit)\n", defaultConfig.getChromeDriver().getVersion(), defaultConfig.getChromeDriver().getBit());
System.out.printf("Current Gecko Driver Version: %s (%s bit)\n", defaultConfig.getGeckoDriver().getVersion(), defaultConfig.getGeckoDriver().getBit());
System.out.printf("Current MsEdge Driver Version: %s (%s bit)\n", defaultConfig.getMsEdgeDriver().getVersion(), defaultConfig.getMsEdgeDriver().getBit());
if (defaultConfig.getIEdriver() != null && defaultConfig.getIEdriver().getVersion() != null)
{
System.out.printf("Current IE Driver Version: %s (%s bit)\n", defaultConfig.getIEdriver().getVersion(), defaultConfig.getIEdriver().getBit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ public static WebDriverReleaseManager getReleaseManager() {
releaseManager =
loadWebDriverReleaseManager("https://selenium-release.storage.googleapis.com/",
"https://chromedriver.storage.googleapis.com/LATEST_RELEASE",
"https://api.github.com/repos/mozilla/geckodriver/releases");
"https://api.github.com/repos/mozilla/geckodriver/releases",
"https://msedgedriver.azureedge.net/LATEST_STABLE");
}

return releaseManager;
Expand All @@ -85,11 +86,13 @@ public static WebDriverReleaseManager getReleaseManager() {

private static WebDriverReleaseManager loadWebDriverReleaseManager(String webDriverAndIEDriverURL,
String chromeDriverUrl,
String geckoDriverUrl) {
String geckoDriverUrl,
String msEdgeDriverUrl) {
try {
return new WebDriverReleaseManager(new URL(webDriverAndIEDriverURL),
new URL(chromeDriverUrl),
new URL(geckoDriverUrl));
new URL(geckoDriverUrl),
new URL(msEdgeDriverUrl));
} catch (MalformedURLException e) {
logger.error("Seems that " + webDriverAndIEDriverURL + " is malformed");
logger.error(e.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public interface BrowserType {

String FIREFOX = "firefox";

@Deprecated
String EDGE = "MicrosoftEdge";

@Deprecated
Expand All @@ -32,6 +33,7 @@ public interface BrowserType {
@Deprecated
String SAFARI_PROXY = "safariproxy";
String CHROME = "chrome";
String MSEDGE = "MicrosoftEdge";
@Deprecated
String KONQUEROR = "konqueror";
@Deprecated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ public static Map<Class, String> getSupportedWebCapabilities() {

capabilityHash.put(Firefox.class, BrowserType.FIREFOX);
capabilityHash.put(InternetExplorer.class, BrowserType.IE);
capabilityHash.put(Edge.class, BrowserType.EDGE);
// capabilityHash.put(Edge.class, BrowserType.EDGE);
capabilityHash.put(Chrome.class, BrowserType.CHROME);
capabilityHash.put(MsEdge.class, BrowserType.MSEDGE);
capabilityHash.put(Safari.class, BrowserType.SAFARI);
capabilityHash.put(PhantomJs.class, BrowserType.PHANTOMJS);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.groupon.seleniumgridextras.config.capabilities;

public class MsEdge extends Capability {

@Override
public String getWebDriverClass() {
return "org.openqa.selenium.edge.EdgeDriver";
}

@Override
public String getIcon() {
return "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALZSURBVDhPXVNfSFNRGP/OOffPNnRRGK5CysiYFFH4kpAPkeJDFPXSWy8FpVAo/YMeepDs1ZdQsN56iDAMLBRBEkQwC4UgI825XDXnrmNzm3Nzu+ecvnPvJPQ3zs653zm/3/2+33cPgV1oiEZ9esS4otmFC4TkDxOSJoQlY5Ran/PGxrvpM+3R8lEHOwTOTmWushLpY1IEkIyRLFCyDkgGRmJA6O+S0OK9xarA44naroLiUPWn0DiZ69C3PINUsACAxJ9AdYE7HGcb5yLOBd2QG50VmeXxy2sPKxXPETg3mW9mttGDSyKFAG4rksRHV8AZxMYYilAJOuGNNJF8gRtAGmZmdE/m1Pd4OFIXi6zAZq4IkmpgGAz2H9ThaNAG02NhGX+A0TBoWgKYyYDpTIKhN1IzfbLl55evdaH5v5CTfpD+GoDKQ1A0qyFqVcLstAZ2qWwVJqXyUiAECANxnS7PLbauJYsAFQcAzD0AzMBdCiSVmADBgpsF//HVFe84biANh1KQ6JESkxCklpU9Ar4ql1gGC38DbWXpDnTXL0D3icV9e/O3QGrINZCE7qA1yivJeZbazF/aJqtESSYJNIU1C3DapOCtACxYx5UHBfQyGbOwxQBFR0LuMTc7mracErgoXnSjGGfeB1gfkn3OEEjmnPcP1r96g20kY+VzLoruiwkXT8xLL4+pNfd5HoHQ26Q0e4TwPrNtren96ddtqtcEBiSD+fAc2hpUh9FVYImYkwVmtIo1t/Ohm0MY2G4Afu/9uhnI1WwN3wu7/en6dR6IGEMRRtYt0BZmADTT2VKQUkZQYApbl5JSVIGwmyQv3OAj90f/34Wn4dt4tE+9mv34BDSbxnYo43aB20LyYqc90vFcPe64TNC11IK3p5dwu46GZvFbsFAORbAcZTG6H5LEvss/dIy6hN0CCo4ny61YcjNZj9eSeISQbCqCPfvIzepheHtNXY4yAP4BZck/RGFnkbYAAAAASUVORK5CYII=";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2013, Groupon, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of GROUPON nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* Created with IntelliJ IDEA.
* User: Dima Kovalenko (@dimacus) && Darko Marinov
* Date: 5/10/13
* Time: 4:06 PM
*/
package com.groupon.seleniumgridextras.config.driver;

import com.groupon.seleniumgridextras.config.RuntimeConfig;

public class MsEdgeDriver extends DriverInfo {

@Override
public String getExecutablePath() {

String
path =
this.getDirectory() + RuntimeConfig.getOS().getFileSeparator() + getExecutableName();

return path;
}

@Override
public String getExecutableName() {
String exe = "msedgedriver_" + this.getVersion() + "_" + this.getBit() + "bit";

if (RuntimeConfig.getOS().isWindows()) {
exe = exe + ".exe";
}
return exe;
}
}
Loading

0 comments on commit 8179334

Please sign in to comment.