diff --git a/SeleniumGridExtras/appium_node1.json b/SeleniumGridExtras/appium_node1.json new file mode 100644 index 00000000..6c7d68a2 --- /dev/null +++ b/SeleniumGridExtras/appium_node1.json @@ -0,0 +1,18 @@ +{ + "capabilities": [], + "configuration": { + "proxy": "com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy", + "servlets": [], + "maxSession": 3, + "port": 4723, + "register": true, + "unregisterIfStillDownAfter": 10000, + "hubPort": 0, + "registerCycle": 5000, + "nodeStatusCheckTimeout": 10000, + "appiumStartCommand": "appium", + "downPollingLimit": 0 + }, + "servlets": [], + "custom": {} +} \ No newline at end of file diff --git a/SeleniumGridExtras/appium_node2.json b/SeleniumGridExtras/appium_node2.json new file mode 100644 index 00000000..aced004c --- /dev/null +++ b/SeleniumGridExtras/appium_node2.json @@ -0,0 +1,18 @@ +{ + "capabilities": [], + "configuration": { + "proxy": "com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy", + "servlets": [], + "maxSession": 3, + "port": 4723, + "register": true, + "unregisterIfStillDownAfter": 10000, + "hubPort": 0, + "registerCycle": 5000, + "nodeStatusCheckTimeout": 10000, + "appiumStartCommand": "appium --avd AVD_NAME", + "downPollingLimit": 0 + }, + "servlets": [], + "custom": {} +} \ No newline at end of file diff --git a/SeleniumGridExtras/edge_download_test.json b/SeleniumGridExtras/edge_download_test.json new file mode 100644 index 00000000..79906e6e --- /dev/null +++ b/SeleniumGridExtras/edge_download_test.json @@ -0,0 +1,30 @@ +{ + "theConfigMap": { + "auto_update_browser_versions": "", + "iedriver": {}, + "auto_update_drivers": "", + "html_render_options": {}, + "node_additional_classpath": [], + "video_recording_options": {}, + "hub_additional_classpath": [], + "geckodriver": {}, + "msedgedriver": { + "directory": "/tmp/download_edge_driver_test" + }, + "reboot_after_sessions": 0, + "tear_down": [], + "webdriver": {}, + "active_modules": [], + "hub_config_files": [], + "unregisterNodeDuringReboot": "true", + "chromedriver": {}, + "disabled_modules": [], + "hub_config": {}, + "grid_extras_port": 3000, + "grid": {}, + "setup": [], + "grid_jvm_options": {}, + "node_config_files": [], + "grid_extras_jvm_options": {} + } +} \ No newline at end of file diff --git a/SeleniumGridExtras/edge_download_test.json.example b/SeleniumGridExtras/edge_download_test.json.example new file mode 100644 index 00000000..c859b206 --- /dev/null +++ b/SeleniumGridExtras/edge_download_test.json.example @@ -0,0 +1,86 @@ +{ + "theConfigMap": { + "auto_update_browser_versions": "", + "log_maximum_size": "20000000", + "iedriver": { + "bit": "Win32", + "directory": "\\tmp\\webdriver\\iedriver", + "version": "2.53.1" + }, + "default_role": "hub", + "auto_update_drivers": "", + "html_render_options": { + "html_footer_partial": "/footer_partial.html", + "main_js_file": "/bootstrap.3.2.0.min.js", + "primary_css_file_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css", + "html_header_file": "/header_partial.html", + "main_template": "/jumbotron-narrow.css", + "primary_css_file": "/bootstrap.3.2.0.min.css", + "main_js_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js", + "jquery_file": "/jquery.1.11.1.min.js", + "jquery_fallback": "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", + "html_nav_bar": "/nav_bar_partial.html", + "main_template_fallback": "http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" + }, + "http_request_timeout": 60000, + "node_additional_classpath": [], + "video_recording_options": { + "frameSeconds": "1", + "frames": "5", + "videos_to_keep": "40", + "lower_third_background_color": "0,0,0,200", + "idle_video_timeout": "120", + "width": "1024", + "video_output_dir": "video_output", + "title_frame_font_color": "129,182,64,128", + "record_test_videos": "true", + "height": "768", + "lower_third_font_color": "255,255,255,255" + }, + "grid_extras_release_url": "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases", + "hub_additional_classpath": [], + "geckodriver": { + "directory": "\\tmp\\webdriver\\geckodriver", + "version": "0.10.0" + }, + "msedgedriver": { + "bit": "32", + "directory": "/tmp/download_edge_driver_test", + "version": "86.0.622.38" + }, + "reboot_after_sessions": 0.0, + "expose_directory": "shared", + "tear_down": [], + "webdriver": { + "directory": "\\tmp\\webdriver", + "version": "2.53.0" + }, + "active_modules": [], + "hub_config_files": [], + "config_puller_http_timeout": 5000, + "auto_start_hub": "0", + "unregisterNodeDuringReboot": "true", + "chromedriver": { + "bit": "32", + "directory": "\\tmp\\webdriver\\chromedriver", + "version": "2.22" + }, + "disabled_modules": [], + "grid_extras_auto_update_check_interval": "86400000", + "auto_start_node": "1", + "hub_config": { + "role": "hub", + "port": "4444", + "servlets": "com.groupon.seleniumgridextras.grid.servlets.ProxyStatusJsonServlet", + "host": "192.168.0.102" + }, + "log_maximum_age_ms": 864000000, + "grid_extras_port": 3000.0, + "grid": {}, + "setup": [], + "grid_jvm_options": {}, + "node_config_files": [], + "grid_extras_jvm_options": {}, + "enable_session_history": "1" + } +} \ No newline at end of file diff --git a/SeleniumGridExtras/grid_start_test.json b/SeleniumGridExtras/grid_start_test.json new file mode 100644 index 00000000..caff443c --- /dev/null +++ b/SeleniumGridExtras/grid_start_test.json @@ -0,0 +1,35 @@ +{ + "theConfigMap": { + "auto_update_browser_versions": "", + "iedriver": {}, + "auto_update_drivers": "", + "html_render_options": {}, + "node_additional_classpath": [], + "video_recording_options": {}, + "hub_additional_classpath": [], + "geckodriver": {}, + "msedgedriver": {}, + "reboot_after_sessions": 0, + "tear_down": [], + "webdriver": { + "version": "1.1.1" + }, + "active_modules": [], + "hub_config_files": [], + "unregisterNodeDuringReboot": "true", + "chromedriver": {}, + "disabled_modules": [], + "hub_config": {}, + "grid_extras_port": 3000, + "grid": {}, + "setup": [], + "grid_jvm_options": {}, + "node_config_files": [ + "node1.json", + "node2.json", + "appium_node1.json", + "appium_node2.json" + ], + "grid_extras_jvm_options": {} + } +} \ No newline at end of file diff --git a/SeleniumGridExtras/node1.json b/SeleniumGridExtras/node1.json new file mode 100644 index 00000000..fed90265 --- /dev/null +++ b/SeleniumGridExtras/node1.json @@ -0,0 +1,17 @@ +{ + "capabilities": [], + "configuration": { + "proxy": "com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy", + "servlets": [], + "maxSession": 3, + "port": 0, + "register": true, + "unregisterIfStillDownAfter": 10000, + "hubPort": 0, + "registerCycle": 5000, + "nodeStatusCheckTimeout": 10000, + "downPollingLimit": 0 + }, + "servlets": [], + "custom": {} +} \ No newline at end of file diff --git a/SeleniumGridExtras/node2.json b/SeleniumGridExtras/node2.json new file mode 100644 index 00000000..fed90265 --- /dev/null +++ b/SeleniumGridExtras/node2.json @@ -0,0 +1,17 @@ +{ + "capabilities": [], + "configuration": { + "proxy": "com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy", + "servlets": [], + "maxSession": 3, + "port": 0, + "register": true, + "unregisterIfStillDownAfter": 10000, + "hubPort": 0, + "registerCycle": 5000, + "nodeStatusCheckTimeout": 10000, + "downPollingLimit": 0 + }, + "servlets": [], + "custom": {} +} \ No newline at end of file diff --git a/SeleniumGridExtras/pom.xml b/SeleniumGridExtras/pom.xml index 60058dce..bb90428c 100644 --- a/SeleniumGridExtras/pom.xml +++ b/SeleniumGridExtras/pom.xml @@ -4,7 +4,7 @@ com.groupon.selenium-grid-extras SeleniumGridExtras - 1.12.20-SNAPSHOT + 2.1.1-SNAPSHOT @@ -13,17 +13,16 @@ xuggle repo - - https://raw.github.com/smccarthy/xuggle-xuggler-dependency/master + https://repository.liferay.com/nexus/content/repositories/public/ - 3.5.3 + 3.8.1 - + net.java.dev.jna jna-platform 4.1.0 @@ -50,10 +49,10 @@ 4.11 test - + commons-io commons-io - 2.4 + 2.5 commons-codec @@ -61,20 +60,20 @@ 1.10 - + org.apache.httpcomponents httpclient - 4.3.1 + 4.5.3 - + org.apache.commons commons-lang3 - 3.3.2 + 3.5 - + com.google.code.gson gson - 2.8.1 + 2.8.2 net.coobird @@ -99,28 +98,23 @@ xuggle xuggle-xuggler - 5.4 + 5.2 org.boofcv xuggler 0.16 - + guava com.google.guava jar 23.0 - org.mockito mockito-core - 2.0.31-beta + 2.12.0 test 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..f3a088fd 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/browser/BrowserVersionDetector.java @@ -25,6 +25,7 @@ public class BrowserVersionDetector { protected File ieDriverPath; protected File chromeDriverPath; protected File geckoDriverPath; + protected File edgeDriverPath; protected List nodesFromConfigFile; public static final String[] chromeMacVersionCommand = {"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", "--version"}; @@ -101,6 +102,7 @@ protected void setDriverPathsInSystemProperty() { System.setProperty("webdriver.ie.driver", this.ieDriverPath.getAbsolutePath()); System.setProperty("webdriver.chrome.driver", this.chromeDriverPath.getAbsolutePath()); System.setProperty("webdriver.gecko.driver", this.geckoDriverPath.getAbsolutePath()); + System.setProperty("webdriver.msedgedriver", this.edgeDriverPath.getAbsolutePath()); } /** @@ -117,6 +119,10 @@ public static String guessBrowserVersion(String browserName) { return getIEVersion(); } else if (browserName.equalsIgnoreCase("internet explorer")) { return getIEVersion(); + } else if (browserName.equalsIgnoreCase("Edge")) { + return getMSEdgeVersion(); + } else if (browserName.equalsIgnoreCase("MicrosoftEdge")) { + return getMSEdgeVersion(); } else { return ""; } @@ -165,11 +171,11 @@ private static String getFirefoxVersion() { String[] cmd = new String[4]; cmd[0] = "cmd"; cmd[1] = "/C"; - File f = new File("C:/Program Files (x86)/Mozilla Firefox"); + File f = new File("C:/Program Files (x86)/Mozilla Firefox/"); if (f.exists()) { cmd[2] = "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"; } else { - cmd[2] = "C:/Program Files/Mozilla Firefox/firefox.exe"; + cmd[2] = "\"C:/Program Files/Mozilla Firefox/firefox.exe\""; } cmd[3] = "--version|more"; @@ -236,4 +242,53 @@ 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; + } + + /* + Get MS Edge version + */ + + private static String getMSEdgeVersion() { + String version =""; + try { + /************ Second Method ****************/ + String cmd = "wmic.exe DATAFILE WHERE \"NAME='C:\\\\Program Files (x86)\\\\Microsoft\\\\Edge\\\\Application\\\\msedge.exe'\" GET Version /value"; + JsonObject object = ExecuteCommand.execRuntime(cmd, true); + logger.info("Detected Edge version: " + object.get("out").getAsJsonArray().get(2).getAsString().trim().replaceAll("[^\\d.]", "")); + version = object.get("out").getAsJsonArray().get(2).getAsString().trim().replaceAll("[^\\d.]", ""); + } catch (Exception e) { + // If ExecuteCommand.execRuntime fails, still return ""; + logger.warn(e.getMessage()); + } + return version; + } + } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/Config.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/Config.java index 6c05bc35..9b52a6ab 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/Config.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/Config.java @@ -21,9 +21,9 @@ public class Config { public static final String GRID = "grid"; public static final String WEBDRIVER = "webdriver"; public static final String IEDRIVER = "iedriver"; - public static final String EDGEDRIVER = "edgedriver"; public static final String CHROME_DRIVER = "chromedriver"; public static final String GECKO_DRIVER = "geckodriver"; + public static final String EDGE_DRIVER = "msedgedriver"; public static final String SHARED_DIR = "expose_directory"; public static final String AUTO_START_NODE = "auto_start_node"; @@ -140,6 +140,7 @@ private void initialize() { initializeIEDriver(); initializeChromeDriver(); initializeGeckoDriver(); + initializeEdgeDriver(); getConfigMap().put(NODE_CONFIG_FILES, new LinkedList()); getConfigMap().put(HUB_CONFIG_FILES, new LinkedList()); @@ -215,6 +216,10 @@ private void initializeGeckoDriver() { getConfigMap().put(GECKO_DRIVER, new GeckoDriver()); } + private void initializeEdgeDriver() { + getConfigMap().put(EDGE_DRIVER, new EdgeDriver()); + } + public void addNodeConfigFile(String filename) { LinkedList files = (LinkedList) getConfigMap().get(NODE_CONFIG_FILES); files.add(filename); @@ -246,6 +251,7 @@ public static Config initilizedFromUserInput() { config.initializeIEDriver(); config.initializeChromeDriver(); config.initializeGeckoDriver(); + config.initializeEdgeDriver(); return FirstTimeRunConfig.customiseConfig(config); } @@ -340,22 +346,22 @@ public DriverInfo getGeckoDriver() { public DriverInfo getEdgeDriver() { try { EdgeDriver driver; - driver = (EdgeDriver) getConfigMap().get(EDGEDRIVER); + driver = (EdgeDriver) getConfigMap().get(EDGE_DRIVER); if (driver == null){ driver = new EdgeDriver(); - getConfigMap().put(EDGEDRIVER, driver); + getConfigMap().put(EDGE_DRIVER, driver); } return driver; } catch (ClassCastException e) { LinkedTreeMap stringMapFromGoogleWhoCantUseHashMapOnNestedObjects = - (LinkedTreeMap) getConfigMap().get(EDGEDRIVER); + (LinkedTreeMap) getConfigMap().get(EDGE_DRIVER); DriverInfo edgeDriver = new EdgeDriver(); edgeDriver.putAll(stringMapFromGoogleWhoCantUseHashMapOnNestedObjects); - getConfigMap().put(EDGEDRIVER, edgeDriver); + getConfigMap().put(EDGE_DRIVER, edgeDriver); return edgeDriver; } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/DefaultConfig.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/DefaultConfig.java index c262dcdc..36292898 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/DefaultConfig.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/DefaultConfig.java @@ -86,12 +86,13 @@ public class DefaultConfig { public static final String ENABLE_SESSION_HISTORY_DEFAULT = "1"; // Session history is turned on by default. public static final File SESSION_LOG_DIRECTORY = new File("log", "session_logs"); public static final int VIDEOS_TO_KEEP = 40; - public static final String DEFAULT_GRID_EXTRAS_RELEASE_URL = "https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases"; + public static final String DEFAULT_GRID_EXTRAS_RELEASE_URL = "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases"; public static final int GRID_EXTRAS_AUTO_UPDATE_CHECK_INTERVAL = 86400000; private static Config config; private static final String webDriverDefaultVersion = "2.53.0"; private static final String ieDriverDefaultVersion = "2.53.1"; private static final String chromeDriverDefaultVersion = "2.22"; + private static final String edgeDriverDefaultVersion = "86.0.622.38"; private static final String geckoDriverDefaultVersion = "0.10.0"; public static Config getDefaultConfig() { @@ -101,6 +102,7 @@ public static Config getDefaultConfig() { loadIEDriverInfo(); loadChromeDriverInfo(); loadGeckoDriverInfo(); + loadEdgeDriverInfo(); loadDisabledPlugins(); loadEnabledPlugins(); loadSetupConfig(); @@ -203,6 +205,9 @@ public static String getIeDriverDefaultVersion() { public static String getChromeDriverDefaultVersion() { return chromeDriverDefaultVersion; } + public static String getEdgeDriverDefaultVersion() { + return edgeDriverDefaultVersion; + } public static String getGeckoDriverDefaultVersion() { return geckoDriverDefaultVersion; @@ -256,6 +261,16 @@ private static void loadGeckoDriverInfo() { config.getGeckoDriver().setVersion(getGeckoDriverDefaultVersion()); } + private static void loadEdgeDriverInfo() { + String tmpDir; + + tmpDir = config.getWebdriver().getDirectory() + RuntimeConfig.getOS().getFileSeparator(); + + config.getEdgeDriver().setDirectory(tmpDir + "msedgedriver"); + config.getEdgeDriver().setVersion(getEdgeDriverDefaultVersion()); + config.getEdgeDriver().setBit(JsonCodec.WebDriver.Downloader.BIT_32); + } + private static void loadLogConfig() { config.setLogMaximumSize(LOG_MAXIMUM_SIZE); config.setLogMaximumAge(LOG_MAX_AGE); @@ -278,6 +293,7 @@ private static void loadEnabledPlugins() { config.addActivatedModules(KillAllIE.class.getCanonicalName()); config.addActivatedModules(KillAllFirefox.class.getCanonicalName()); config.addActivatedModules(KillAllChrome.class.getCanonicalName()); + config.addActivatedModules(KillAllEdge.class.getCanonicalName()); config.addActivatedModules(KillAllSafari.class.getCanonicalName()); config.addActivatedModules(SetAutoLogonUser.class.getCanonicalName()); @@ -305,6 +321,7 @@ private static void loadEnabledPlugins() { config.addActivatedModules(DownloadIEDriver.class.getCanonicalName()); config.addActivatedModules(DownloadChromeDriver.class.getCanonicalName()); config.addActivatedModules(DownloadGeckoDriver.class.getCanonicalName()); + config.addActivatedModules(DownloadEdgeDriver.class.getCanonicalName()); config.addActivatedModules(SessionHistory.class.getCanonicalName()); config.addActivatedModules(UpgradeGridExtrasTask.class.getCanonicalName()); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfig.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfig.java index 678ae490..fe387857 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfig.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfig.java @@ -46,6 +46,7 @@ import com.groupon.seleniumgridextras.config.capabilities.Capability; import com.groupon.seleniumgridextras.config.remote.ConfigPusher; import com.groupon.seleniumgridextras.downloader.ChromeDriverDownloader; +import com.groupon.seleniumgridextras.downloader.EdgeDriverDownloader; import com.groupon.seleniumgridextras.downloader.GeckoDriverDownloader; import com.groupon.seleniumgridextras.downloader.webdriverreleasemanager.WebDriverReleaseManager; import com.groupon.seleniumgridextras.os.GridPlatform; @@ -274,13 +275,14 @@ private static void setDriverAutoUpdater(Config defaultConfig) { String answer = askQuestion( - "Would you like WebDriver, IEDriver, ChromeDriver and GeckoDriver to auto update (1-yes/0-no)", "1"); + "Would you like WebDriver, IEDriver, ChromeDriver, GeckoDriver and Edge to auto update (1-yes/0-no)", "1"); WebDriverReleaseManager manager = RuntimeConfig.getReleaseManager(); String versionOfChrome = manager.getChromeDriverLatestVersion().getPrettyPrintVersion("."); String versionOfGecko = manager.getGeckoDriverLatestVersion().getPrettyPrintVersion("."); String versionOfWebDriver = manager.getWedriverLatestVersion().getPrettyPrintVersion("."); String versionOfIEDriver = manager.getIeDriverLatestVersion().getPrettyPrintVersion("."); + String versionOfEdgeDriver = manager.getEdgeDriverLatestVersion().getPrettyPrintVersion("."); if (answer.equals("1")) { defaultConfig.setAutoUpdateDrivers("1"); @@ -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); + versionOfEdgeDriver = + askQuestion("What version of Edge Driver should we use?", versionOfEdgeDriver); } defaultConfig.getChromeDriver().setVersion(versionOfChrome); defaultConfig.getGeckoDriver().setVersion(versionOfGecko); + defaultConfig.getEdgeDriver().setVersion(versionOfEdgeDriver); if(gridExtrasVersion.startsWith("1.")) { if(VersionCompare.versionCompare(versionOfWebDriver, "3.7.1") >= 0) { @@ -336,7 +341,7 @@ private static void setDriverAutoUpdater(Config defaultConfig) { defaultConfig.getIEdriver().setBit(bitOfIEDriver); } - String bitOfGeckoDriver = JsonCodec.WebDriver.Downloader.BIT_32; + String bitOfGeckoDriver = JsonCodec.WebDriver.Downloader.BIT_64; String[] bitVersionsGeckoDriver = GeckoDriverDownloader.getBitArchitecturesForVersion(versionOfGecko); if (bitVersionsGeckoDriver.length > 1) { bitOfGeckoDriver = askQuestion("What bit of GeckoDriver should we use (" + StringUtils.join(bitVersionsGeckoDriver, ", ") + ")?", JsonCodec.WebDriver.Downloader.BIT_32); @@ -347,8 +352,20 @@ private static void setDriverAutoUpdater(Config defaultConfig) { } defaultConfig.getGeckoDriver().setBit(bitOfGeckoDriver); + String bitOfEdgeDriver = JsonCodec.WebDriver.Downloader.BIT_64; +/* String[] bitVersionsEdgeDriver = EdgeDriverDownloader.getBitArchitecturesForVersion(versionOfEdgeDriver); + if (bitVersionsEdgeDriver.length > 1) { + bitOfEdgeDriver = askQuestion("What bit of EdgeDriver should we use (" + StringUtils.join(bitVersionsChromeDriver, ", ") + ")?", JsonCodec.WebDriver.Downloader.BIT_32); + } else if (bitVersionsChromeDriver.length == 1) { + bitOfEdgeDriver = bitVersionsEdgeDriver[0]; + } else { + System.out.println("\nWARNING: We were unable to find the correct bit of EdgeDriver for this OS and EdgeDriver version: " + versionOfEdgeDriver + " so will default to '32' please update this to be more accurate, or grid may not function properly\n"); + }*/ + defaultConfig.getEdgeDriver().setBit(bitOfEdgeDriver); + 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 Edge Driver Version: %s (%s bit)\n", defaultConfig.getEdgeDriver().getVersion(), defaultConfig.getEdgeDriver().getBit()); System.out.printf("Current Gecko Driver Version: %s (%s bit)\n", defaultConfig.getGeckoDriver().getVersion(), defaultConfig.getGeckoDriver().getBit()); if (defaultConfig.getIEdriver() != null && defaultConfig.getIEdriver().getVersion() != null) { diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/GridNode.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/GridNode.java index d5d92e2c..e0b2da8a 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/GridNode.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/GridNode.java @@ -65,6 +65,8 @@ public GridNode(boolean isSelenium3) { registerCycle = 5000; nodeStatusCheckTimeout = 10000; downPollingLimit = 0; + // Init custom with grid_extras_port value from node + custom.put(Config.GRID_EXTRAS_PORT, RuntimeConfig.getGridExtrasPort()); } } @@ -131,6 +133,11 @@ public static GridNode loadFromFile(String filename, boolean isSelenium3) { if(topLevelJson.get("custom") != null) { Map customMap = new Gson().fromJson(topLevelJson.get("custom"), type); doubleToIntConverter(customMap); + // Init custom with grid_extras_port value from node if it doesn't exist + if (!customMap.containsKey(Config.GRID_EXTRAS_PORT)) + { + customMap.put(Config.GRID_EXTRAS_PORT, RuntimeConfig.getGridExtrasPort()); + } node.setCustom(customMap); } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/RuntimeConfig.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/RuntimeConfig.java index 7ff3708d..ca5c53ee 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/RuntimeConfig.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/RuntimeConfig.java @@ -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://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_STABLE"); } return releaseManager; @@ -85,11 +86,12 @@ public static WebDriverReleaseManager getReleaseManager() { private static WebDriverReleaseManager loadWebDriverReleaseManager(String webDriverAndIEDriverURL, String chromeDriverUrl, - String geckoDriverUrl) { + String geckoDriverUrl, String edgeDriverUrl) { try { return new WebDriverReleaseManager(new URL(webDriverAndIEDriverURL), new URL(chromeDriverUrl), - new URL(geckoDriverUrl)); + new URL(geckoDriverUrl), + new URL(edgeDriverUrl)); } catch (MalformedURLException e) { logger.error("Seems that " + webDriverAndIEDriverURL + " is malformed"); logger.error(e.toString()); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/capabilities/Edge.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/capabilities/Edge.java index de2a5c4b..119c07ee 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/capabilities/Edge.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/capabilities/Edge.java @@ -3,7 +3,11 @@ public class Edge extends Capability { @Override public String getWebDriverClass() { - return "org.openqa.selenium.edge.EdgeDriver"; + return "microsoft.edge.seleniumtools.edgeDriver"; + } + + public Edge() { + this.put("maxInstances", 3); } @Override diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/driver/EdgeDriver.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/driver/EdgeDriver.java index 77927536..58f34421 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/driver/EdgeDriver.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/config/driver/EdgeDriver.java @@ -1,14 +1,20 @@ package com.groupon.seleniumgridextras.config.driver; +import com.groupon.seleniumgridextras.config.RuntimeConfig; + public class EdgeDriver extends DriverInfo { @Override public String getExecutablePath() { - return "C:\\Program Files (x86)\\Microsoft Web Driver\\" + getExecutableName(); + String + path = + this.getDirectory() + RuntimeConfig.getOS().getFileSeparator() + getExecutableName(); + + return path; } @Override public String getExecutableName() { - return "MicrosoftWebDriver.exe"; + return "msedgedriver.exe"; } } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloader.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloader.java new file mode 100644 index 00000000..506d0045 --- /dev/null +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloader.java @@ -0,0 +1,255 @@ +/** + * 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.downloader; + +import com.groupon.seleniumgridextras.config.RuntimeConfig; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.log4j.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import sun.net.www.http.ChunkedInputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class EdgeDriverDownloader extends Downloader { + + private String bit; + private String version; + private static final String EDGEDRIVER_BASE_URL = "https://msedgedriver.azureedge.net/"; + private static Logger logger = Logger.getLogger(EdgeDriverDownloader.class); + + public EdgeDriverDownloader(String version, String bitVersion) { + setDestinationDir(RuntimeConfig.getConfig().getEdgeDriver().getDirectory()); + setVersion(version); + setBitVersion(bitVersion); + + setDestinationFile(getVersion() + "_" + getBitVersion() + "bit" + ".zip"); + + //https://msedgedriver.azureedge.net/87.0.669.0/edgedriver_win64.zip + setSourceURL(EDGEDRIVER_BASE_URL + getVersion() + "/edgedriver_" + + getOSName() + getBitVersion() + ".zip"); + + } + + @Override + public void setSourceURL(String source) { + sourceURL = source; + } + + @Override + public void setDestinationFile(String destination) { + destinationFile = destination; + } + + @Override + public void setDestinationDir(String dir) { + destinationDir = dir; + } + + @Override + public boolean download() { + logger.info("Downloading from " + getSourceURL()); + if (startDownload()) { + if (Unzipper.unzip(getDestinationFileFullPath().getAbsolutePath(), getDestinationDir())) { + String edgedriver = "msedgedriver"; + if (RuntimeConfig.getOS().isWindows()){ + edgedriver = edgedriver + ".exe"; + } + File tempUnzipedExecutable = new File(getDestinationDir(), edgedriver); + File finalExecutable = + new File(RuntimeConfig.getConfig().getEdgeDriver().getExecutablePath()); + + if (tempUnzipedExecutable.exists()){ + logger.debug(tempUnzipedExecutable.getAbsolutePath()); + logger.debug("It does exist"); + logger.debug(finalExecutable.getAbsolutePath()); + } else { + logger.debug(tempUnzipedExecutable.getAbsolutePath()); + logger.debug("NO exist"); + logger.debug(finalExecutable.getAbsolutePath()); + } + + tempUnzipedExecutable.renameTo(finalExecutable); + + setDestinationFile(finalExecutable.getAbsolutePath()); + + finalExecutable.setExecutable(true, false); + finalExecutable.setReadable(true, false); + + return true; + } + } + return false; + } + + + public String getBitVersion() { + return bit; + } + + public void setBitVersion(String bit) { + this.bit = bit; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + protected static String getOSName() { + String os; + + if (RuntimeConfig.getOS().isWindows()) { + os = getWindowsName(); + } else if (RuntimeConfig.getOS().isMac()) { + os = getMacName(); + } else { + os = getLinuxName(); + } + + return os; + } + + protected static String getLinuxName() { + return "linux"; + } + + protected static String getMacName() { + return "mac"; + } + + protected static String getWindowsName() { + return "win"; + } + + public static String[] getBitArchitecturesForVersion(String edgeDriverVersionNumber) { + ArrayList bitArchitecturesAvailable = new ArrayList(); + try { + String xpathString = "//*[text()[contains(.,'" + edgeDriverVersionNumber + "/edgedriver_" + getOSName() + "')]]"; + XPathExpression expression = XPathFactory.newInstance().newXPath().compile(xpathString); + + NodeList result = (NodeList) expression.evaluate(getVersionManifest(), XPathConstants.NODESET); + + for (int i = 0; i < result.getLength(); i++) { + String nodeValue = result.item(i).getTextContent(); + Matcher matcher = Pattern.compile("(\\d{2})(?=.zip)").matcher(nodeValue); + while (matcher.find()) + { + bitArchitecturesAvailable.add(matcher.group(1)); + } + } + } + catch (XPathExpressionException e) { + logger.error(e.toString()); + } + finally { + return bitArchitecturesAvailable.toArray(new String[] {}); + } + } + + private static Document getVersionManifest() throws IOException, ParserConfigurationException { + HttpClient httpClient = new DefaultHttpClient(); + HttpGet httpGet = new HttpGet(EDGEDRIVER_BASE_URL); + httpGet.addHeader("user-agent", "Apache-HttpClient/5.0"); + httpGet.addHeader("accept-encoding", "gzip, deflate, br"); + httpGet.addHeader("cache-control", "max-age=0"); + httpGet.addHeader("connection", "keep-alive"); + + HttpResponse response = httpClient.execute(httpGet); + + InputStream inputStream = response.getEntity().getContent(); + String xmlStr = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)).readLine(); + +/* + Properties versionsProperties = new Properties(); + versionsProperties.load(inputStream); + String xmlStr = versionsProperties.getProperty("()); allProducts.put(CHROME_DRIVER, new LinkedList()); allProducts.put(GECKO_DRIVER, new LinkedList()); + allProducts.put(EDGE_DRIVER, new LinkedList()); } - public WebDriverReleaseManager(URL webDriverAndIEDriverURL, URL chromeDriverVersionURL, URL geckoDriverVersionURL) + public WebDriverReleaseManager(URL webDriverAndIEDriverURL, URL chromeDriverVersionURL, URL geckoDriverVersionURL, URL edgeDriverVersionURL) throws DocumentException { - logger.info("Checking the latest version of WebDriver, IEDriver, ChromeDriver and GeckoDriver from " - + webDriverAndIEDriverURL.toExternalForm() + " and " + chromeDriverVersionURL + " and " + geckoDriverVersionURL + logger.info("Checking the latest version of WebDriver, IEDriver, ChromeDriver, GeckoDriver and MSEdgeDriver from " + + webDriverAndIEDriverURL.toExternalForm() + " and " + chromeDriverVersionURL + " and " + geckoDriverVersionURL + " and " + edgeDriverVersionURL .toExternalForm()); initialize(); @@ -59,6 +63,7 @@ public WebDriverReleaseManager(URL webDriverAndIEDriverURL, URL chromeDriverVers loadWebDriverAndIEDriverVersions(parsedXml); loadChromeDriverVersionFromURL(chromeDriverVersionURL); loadGeckoDriverVersionFromURL(geckoDriverVersionURL); + loadEdgeDriverVersionFromURL(edgeDriverVersionURL); } public int getWebdriverVersionCount() { @@ -94,6 +99,11 @@ public WebDriverRelease getGeckoDriverLatestVersion() { return this.latestGeckoDriverVersion; } + public WebDriverRelease getEdgeDriverLatestVersion() { + logger.debug("latestEdgeDriverVersion : " + this.latestEdgeDriverVersion); + return this.latestEdgeDriverVersion; + } + /* * Choose the greatest major version. * If major version is the same, choose the greatest comparable version. @@ -119,16 +129,12 @@ private WebDriverRelease findLatestRelease(List list) { } public void loadChromeDriverVersionFromURL(URL url) { - InputStream in = null; try { - in = url.openStream(); - loadChromeDriverVersion(IOUtils.toString(in)); + loadChromeDriverVersion(IOUtils.toString(url, StandardCharsets.UTF_8)); } catch (IOException e) { logger.error("Something went wrong when trying to get latest chrome driver version"); logger.error(e.toString()); e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. - } finally { - IOUtils.closeQuietly(in); } } @@ -171,4 +177,18 @@ public void loadWebDriverAndIEDriverVersions(Document xml) { } } + public void loadEdgeDriverVersionFromURL(URL url){ + try { + loadEdgeDriverVersion(IOUtils.toString(url, StandardCharsets.UTF_8)); + } catch (IOException e) { + logger.error("Something went wrong when trying to get latest edge driver version"); + logger.error(e.toString()); + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + } + + public void loadEdgeDriverVersion(String version) { + this.latestEdgeDriverVersion = new EdgeDriverRelease(version); + } + } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/GridStarter.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/GridStarter.java index 6dadd92c..164834fa 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/GridStarter.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/GridStarter.java @@ -202,11 +202,11 @@ protected static List getWebNodeStartCommand(String configFile, Boolean } if (windows) { command.add(getIEDriverExecutionPathParam(config)); - command.add(getEdgeDriverExecutionPathParam(config)); } command.add(getChromeDriverExecutionPathParam(config)); command.add(getGeckoDriverExecutionPathParam(config)); + command.add(getEdgeDriverExecutionPathParam(config)); command.add("-cp"); String cp = getGridExtrasJarFilePath(); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/AutoProxy.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/AutoProxy.java index aefb48aa..046c9cd7 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/AutoProxy.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/AutoProxy.java @@ -3,7 +3,7 @@ import org.openqa.grid.common.RegistrationRequest; import org.openqa.grid.common.exception.RemoteUnregisterException; -import org.openqa.grid.internal.Registry; +import org.openqa.grid.internal.GridRegistry; import org.openqa.grid.internal.TestSession; import org.openqa.grid.internal.listeners.SelfHealingProxy; import org.openqa.grid.internal.utils.HtmlRenderer; @@ -24,7 +24,7 @@ public class AutoProxy extends DefaultRemoteProxy implements SelfHealingProxy { private Date startTime; private HtmlRenderer renderer = new ExtrasHtmlRenderer(this); - public AutoProxy(RegistrationRequest request, Registry registry) { + public AutoProxy(RegistrationRequest request, GridRegistry registry) { super(request, registry); NodeManager nodeManager = new NodeManager(this); new Thread(nodeManager).start(); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/SetupTeardownProxy.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/SetupTeardownProxy.java index 1d711ac4..d9649799 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/SetupTeardownProxy.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/SetupTeardownProxy.java @@ -39,6 +39,7 @@ package com.groupon.seleniumgridextras.grid.proxies; import com.google.common.base.Throwables; +import com.groupon.seleniumgridextras.config.Config; import com.groupon.seleniumgridextras.config.RuntimeConfig; import com.groupon.seleniumgridextras.config.capabilities.BrowserType; import com.groupon.seleniumgridextras.grid.proxies.sessions.threads.NodeRestartCallable; @@ -52,11 +53,12 @@ import com.groupon.seleniumgridextras.utilities.threads.video.VideoDownloaderCallable; import org.apache.log4j.Logger; import org.openqa.grid.common.RegistrationRequest; -import org.openqa.grid.internal.Registry; +import org.openqa.grid.internal.GridRegistry; import org.openqa.grid.internal.TestSession; import org.openqa.grid.internal.listeners.TestSessionListener; import org.openqa.grid.selenium.proxy.DefaultRemoteProxy; import org.openqa.selenium.remote.CapabilityType; +import org.openqa.selenium.remote.server.jmx.ManagedService; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -68,7 +70,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; - +@ManagedService(description = "Selenium-Grid-Extras SetupTeardownProxy") public class SetupTeardownProxy extends DefaultRemoteProxy implements TestSessionListener { private boolean available = true; @@ -78,12 +80,11 @@ public class SetupTeardownProxy extends DefaultRemoteProxy implements TestSessio private static Logger logger = Logger.getLogger(SetupTeardownProxy.class); - public SetupTeardownProxy(RegistrationRequest request, Registry registry) { + public SetupTeardownProxy(RegistrationRequest request, GridRegistry registry) { super(request, registry); logger.info(String.format("Attaching node %s", this.getId())); } - @Override public TestSession getNewSession(Map requestedCapability) { if (isDown() || isRestarting()) { @@ -106,13 +107,14 @@ public TestSession getNewSession(Map requestedCapability) { try { String host = session.getSlot().getRemoteURL().getHost(); + int port = getNodeExtrasPort(session); logNewSessionHistoryAsync(session); CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( host, - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.SETUP, new HashMap())); @@ -142,6 +144,7 @@ public void afterSession(TestSession session) { Map cap = session.getRequestedCapabilities(); String browser = (String) cap.get(CapabilityType.BROWSER_NAME); + int port = getNodeExtrasPort(session); if (browser != null && (browser.equals(BrowserType.IE) || @@ -151,7 +154,7 @@ public void afterSession(TestSession session) { CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( this.getRemoteHost().getHost(), - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.KILL_IE, new HashMap())); } @@ -169,19 +172,20 @@ public void afterSession(TestSession session) { CommonThreadPool.startCallable( new VideoDownloaderCallable( session.getExternalKey().getKey(), - session.getSlot().getRemoteURL().getHost())); + session.getSlot().getRemoteURL().getHost(), + getNodeExtrasPort(session))); } } CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( this.getRemoteHost().getHost(), - RuntimeConfig.getGridExtrasPort(), + getNodeExtrasPort(session), TaskDescriptions.Endpoints.TEARDOWN, new HashMap())); - if (NodeRestartCallable.timeToReboot(this.getRemoteHost().getHost(), this.getId())) { + if (NodeRestartCallable.timeToReboot(this.getRemoteHost().getHost(), this.getId(), session)) { this.setAvailable(false); this.setRestarting(true); @@ -302,4 +306,18 @@ public static Future logNewSessionHistoryAsync(TestSession session) { return null; } + public static int getNodeExtrasPort(TestSession session){ + try { + + String port = session.getSlot().getProxy().getConfig().custom.get(Config.GRID_EXTRAS_PORT); + if(port!= null || ! port.equals("")) { + return Integer.parseInt(port); + } + }catch(NumberFormatException e) + { + logger.info("Error parsing port, returning default"); + } + return RuntimeConfig.getGridExtrasPort(); + } + } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/NodeRestartCallable.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/NodeRestartCallable.java index 29c15eea..21d3d18c 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/NodeRestartCallable.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/NodeRestartCallable.java @@ -52,7 +52,7 @@ public String call() throws Exception { } stopGridNode(); - NodeRestartCallable.rebootGridExtrasNode(proxy.getRemoteHost().getHost()); + NodeRestartCallable.rebootGridExtrasNode(proxy.getRemoteHost().getHost(), session); logger.info(String.format("Proxy restart command sent for %s", proxy.getId())); return "Done"; @@ -78,12 +78,13 @@ public void waitForProxyToFreeUp() { } - public static void rebootGridExtrasNode(String host) { + public static void rebootGridExtrasNode(String host, TestSession session) { logger.info("Asking SeleniumGridExtras to reboot node" + host); + int port = SetupTeardownProxy.getNodeExtrasPort(session); Future f = CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( host, - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.REBOOT, new HashMap())); try { @@ -97,6 +98,8 @@ public static void rebootGridExtrasNode(String host) { public void stopGridNode() { logger.info(String.format("Asking proxy %s to stop gracefully", proxy.getId())); + + int port = SetupTeardownProxy.getNodeExtrasPort(session); Map params = new HashMap(); params.put(JsonCodec.WebDriver.Grid.PORT, String.valueOf(proxy.getRemoteHost().getPort())); @@ -104,7 +107,7 @@ public void stopGridNode() { Future f = CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( proxy.getRemoteHost().getHost(), - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.STOP_GRID, params)); @@ -118,11 +121,12 @@ public void stopGridNode() { public void unregister() { boolean unregisterDuringReboot = true; - + int port = SetupTeardownProxy.getNodeExtrasPort(session); + Future f = CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( proxy.getRemoteHost().getHost(), - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.GRID_STATUS, new HashMap())); @@ -154,11 +158,12 @@ public void unregister() { } } - public static boolean timeToReboot(String nodeHost, String proxyId) { + public static boolean timeToReboot(String nodeHost, String proxyId, TestSession session) { + int port = SetupTeardownProxy.getNodeExtrasPort(session); Future f = CommonThreadPool.startCallable( new RemoteGridExtrasAsyncCallable( nodeHost, - RuntimeConfig.getGridExtrasPort(), + port, TaskDescriptions.Endpoints.GRID_STATUS, new HashMap())); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ListNodesServlet.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ListNodesServlet.java new file mode 100644 index 00000000..bfd9301f --- /dev/null +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ListNodesServlet.java @@ -0,0 +1,66 @@ +package com.groupon.seleniumgridextras.grid.servlets; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.openqa.grid.internal.Registry; +import org.openqa.grid.internal.ProxySet; +import org.openqa.grid.internal.RemoteProxy; +import org.openqa.grid.web.servlet.RegistryBasedServlet; + +import com.google.gson.GsonBuilder; + +public class ListNodesServlet extends RegistryBasedServlet { + + private static final long serialVersionUID = 1L; + + public ListNodesServlet() { + this(null); + } + + public ListNodesServlet(Registry registry) { + super(registry); + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + doPost(req, resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + process(req, resp); + } + + protected void process(HttpServletRequest request, HttpServletResponse response) throws IOException { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + response.setStatus(200); + + response.getWriter().print(new GsonBuilder().setPrettyPrinting().create().toJson(getResponse())); + response.getWriter().close(); + } + + private Map> getResponse() throws IOException { + Map> res = new HashMap<>(); + ArrayList nodeList = new ArrayList<>(); + + ProxySet proxies = this.getRegistry().getAllProxies(); + Iterator iterator = proxies.iterator(); + while (iterator.hasNext()) { + RemoteProxy eachProxy = iterator.next(); + nodeList.add(String.format("%s:%s", eachProxy.getConfig().host, eachProxy.getConfig().custom.get("grid_extras_port"))); + } + + res.put("nodeList", nodeList); + return res; + } +} diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ProxyStatusJsonServlet.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ProxyStatusJsonServlet.java index 6ad05a42..0d3fbab7 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ProxyStatusJsonServlet.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/servlets/ProxyStatusJsonServlet.java @@ -3,7 +3,7 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import org.openqa.grid.internal.ProxySet; -import org.openqa.grid.internal.Registry; +import org.openqa.grid.internal.GridRegistry; import org.openqa.grid.internal.RemoteProxy; import org.openqa.grid.internal.TestSlot; import org.openqa.grid.web.servlet.RegistryBasedServlet; @@ -27,7 +27,7 @@ public ProxyStatusJsonServlet() { this(null); } - public ProxyStatusJsonServlet(Registry registry) { + public ProxyStatusJsonServlet(GridRegistry registry) { super(registry); } @@ -102,4 +102,3 @@ private Map getResponse() { } } - diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/homepage/HtmlNodeRenderer.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/homepage/HtmlNodeRenderer.java index e50db9ee..04baa837 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/homepage/HtmlNodeRenderer.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/homepage/HtmlNodeRenderer.java @@ -275,7 +275,10 @@ private String getDriverVersion(String browserName) { return RuntimeConfig.getConfig().getIEdriver().getVersion(); } else if (browserName.equalsIgnoreCase("firefox")) { return RuntimeConfig.getConfig().getGeckoDriver().getVersion(); - } else { + } else if (browserName.equalsIgnoreCase("msedge")) { + return RuntimeConfig.getConfig().getEdgeDriver().getVersion(); + } + else { return RuntimeConfig.getConfig().getWebdriver().getVersion(); } } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDrivers.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDrivers.java index 43b8b01a..ff0cc5bc 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDrivers.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDrivers.java @@ -22,6 +22,7 @@ public class AutoUpgradeDrivers extends ExecuteOSTask { private boolean updateIEDriver = false; private boolean updateChromeDriver = false; private boolean updateGeckoDriver = false; + private boolean updateEdgeDriver = false; public AutoUpgradeDrivers() { setEndpoint(TaskDescriptions.Endpoints.AUTO_UPGRADE_WEBDRIVER); @@ -35,21 +36,25 @@ public AutoUpgradeDrivers() { addResponseDescription(JsonCodec.WebDriver.OLD_CHROME_DRIVER, "Old version of Chrome Driver"); addResponseDescription(JsonCodec.WebDriver.OLD_GECKO_DRIVER, "Old version of Gecko Driver"); addResponseDescription(JsonCodec.WebDriver.OLD_IE_DRIVER, "Old version of IE Driver"); + addResponseDescription(JsonCodec.WebDriver.OLD_EDGE_DRIVER, "Old version of Edge Driver"); addResponseDescription(JsonCodec.WebDriver.NEW_WEB_DRIVER_JAR, "New versions of WebDriver Jar"); addResponseDescription(JsonCodec.WebDriver.NEW_CHROME_DRIVER, "New version of Chrome Driver"); addResponseDescription(JsonCodec.WebDriver.NEW_GECKO_DRIVER, "New version of Gecko Driver"); addResponseDescription(JsonCodec.WebDriver.NEW_IE_DRIVER, "New version of IE Driver"); + addResponseDescription(JsonCodec.WebDriver.NEW_CHROME_DRIVER, "New version of Edge Driver"); getJsonResponse().addKeyValues(JsonCodec.WebDriver.OLD_WEB_DRIVER_JAR, RuntimeConfig.getConfig().getWebdriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.OLD_CHROME_DRIVER, RuntimeConfig.getConfig().getChromeDriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.OLD_GECKO_DRIVER, RuntimeConfig.getConfig().getGeckoDriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.OLD_IE_DRIVER, RuntimeConfig.getConfig().getIEdriver().getVersion()); + getJsonResponse().addKeyValues(JsonCodec.WebDriver.OLD_EDGE_DRIVER, RuntimeConfig.getConfig().getEdgeDriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_WEB_DRIVER_JAR, RuntimeConfig.getConfig().getWebdriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_CHROME_DRIVER, RuntimeConfig.getConfig().getChromeDriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_GECKO_DRIVER, RuntimeConfig.getConfig().getGeckoDriver().getVersion()); getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_IE_DRIVER, RuntimeConfig.getConfig().getIEdriver().getVersion()); + getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_EDGE_DRIVER, RuntimeConfig.getConfig().getEdgeDriver().getVersion()); } @@ -85,6 +90,17 @@ public JsonObject execute() { updateVersionFor(configHash, "geckodriver", newGeckoDriverVersion); getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_GECKO_DRIVER, newGeckoDriverVersion); } + if (updateEdgeDriver) { + String + newEdgeDriverVersion = + RuntimeConfig.getReleaseManager().getEdgeDriverLatestVersion().getPrettyPrintVersion( + "."); + logger.info("Edge Driver " + genericUpdate + " " + newEdgeDriverVersion); + RuntimeConfig.getConfig().getEdgeDriver().setVersion(newEdgeDriverVersion); + + updateVersionFor(configHash, "msedgedriver", newEdgeDriverVersion); + getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_EDGE_DRIVER, newEdgeDriverVersion); + } if (updateWebDriver) { String gridExtrasVersion = Version.getSanitizedVersion(); @@ -122,7 +138,7 @@ public JsonObject execute() { getJsonResponse().addKeyValues(JsonCodec.WebDriver.NEW_IE_DRIVER, newIEDriverVersion); } - if (updateChromeDriver || updateIEDriver || updateWebDriver || updateGeckoDriver) { + if (updateChromeDriver || updateIEDriver || updateWebDriver || updateGeckoDriver || updateEdgeDriver) { String message = "Update was detected for one or more versions of the drivers. You may need to restart Grid Extras for new versions to work"; @@ -198,10 +214,18 @@ private void checkWhoNeedsUpdates() { updateWebDriver = currentWebDriverJarVersion != newestWebDriverJarVersion; + int + currentEdgeVersion = + getComparableVersion(RuntimeConfig.getConfig().getEdgeDriver().getVersion()); + int + newestEdgeVersion = + RuntimeConfig.getReleaseManager().getEdgeDriverLatestVersion().getComparableVersion(); + + updateEdgeDriver = currentEdgeVersion < newestEdgeVersion; } private Integer getComparableVersion(String version) { - return Integer.valueOf(version.replace(".", "0")); + return Integer.valueOf(version.replace(".", "")); } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriver.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriver.java new file mode 100644 index 00000000..3e92a788 --- /dev/null +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriver.java @@ -0,0 +1,179 @@ +/** + * 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.tasks; + +import com.google.gson.JsonObject; +import com.groupon.seleniumgridextras.config.RuntimeConfig; +import com.groupon.seleniumgridextras.downloader.EdgeDriverDownloader; +import com.groupon.seleniumgridextras.downloader.Downloader; +import com.groupon.seleniumgridextras.tasks.config.TaskDescriptions; +import com.groupon.seleniumgridextras.utilities.json.JsonCodec; +import org.apache.log4j.Logger; + +import java.io.File; +import java.util.Map; + +public class DownloadEdgeDriver extends ExecuteOSTask { + + private String bit = JsonCodec.WebDriver.Downloader.BIT_32; + private static Logger logger = Logger.getLogger(DownloadEdgeDriver.class); + + public DownloadEdgeDriver() { + setEndpoint(TaskDescriptions.Endpoints.DOWNLOAD_EDGEDRIVER); + setDescription(TaskDescriptions.Description.DOWNLOAD_EDGEDRIVER); + JsonObject params = new JsonObject(); + params.addProperty(JsonCodec.WebDriver.Downloader.VERSION, + "Version of EdgeDriver to download, such as 2.6"); + params.addProperty(JsonCodec.WebDriver.Downloader.BIT, + "Bit Version of EdgeDriver 32/64 - (default: 32)"); + setAcceptedParams(params); + setRequestType(TaskDescriptions.HTTP.GET); + setResponseType(TaskDescriptions.HTTP.JSON); + setClassname(this.getClass().getCanonicalName().toString()); + setCssClass(TaskDescriptions.UI.BTN_SUCCESS); + setButtonText(TaskDescriptions.UI.ButtonText.DOWNLOAD_EDGEDRIVER); + setEnabledInGui(true); + + addResponseDescription(JsonCodec.WebDriver.Downloader.ROOT_DIR, + "Directory to which executable file was saved to"); + addResponseDescription(JsonCodec.WebDriver.Downloader.FILE, + "Relative path to file on the node"); + addResponseDescription(JsonCodec.WebDriver.Downloader.FILE_FULL_PATH, + "Full path to file on node"); + addResponseDescription(JsonCodec.WebDriver.Downloader.SOURCE_URL, + "Url from which the executable was downloaded. If file already exists, this will be blank, and download will be skipped"); + + // bit value should be initialized from configuration + this.bit = RuntimeConfig.getConfig().getEdgeDriver().getBit(); + + logger.debug(RuntimeConfig.getConfig()); + getJsonResponse() + .addKeyValues(JsonCodec.WebDriver.Downloader.ROOT_DIR, + RuntimeConfig.getConfig().getEdgeDriver().getDirectory()); + getJsonResponse().addKeyValues( + JsonCodec.WebDriver.Downloader.SOURCE_URL, ""); + + } + + @Override + public JsonObject execute() { + return execute(RuntimeConfig.getConfig().getEdgeDriver().getVersion()); + } + + @Override + public JsonObject execute(Map parameter) { + + if (!parameter.isEmpty() && parameter.containsKey( + JsonCodec.WebDriver.Downloader.VERSION)) { + if (parameter.containsKey(JsonCodec.WebDriver.Downloader.BIT)) { + this.bit = parameter.get(JsonCodec.WebDriver.Downloader.BIT).toString(); + } else { + this.bit = JsonCodec.WebDriver.Downloader.BIT_32; + } + return execute(parameter.get(JsonCodec.WebDriver.Downloader.VERSION).toString()); + } else { + return execute(); + } + } + + @Override + public JsonObject execute(String version) { + + Downloader + downloader = + new EdgeDriverDownloader(version, this.bit); + + if (!new File(RuntimeConfig.getConfig().getEdgeDriver().getExecutablePath()).exists()) { + Boolean downloaded = downloader.download(); + getJsonResponse().addKeyValues( + JsonCodec.WebDriver.Downloader.SOURCE_URL, downloader.getSourceURL()); + + if (!downloaded) { + getJsonResponse().addKeyValues(JsonCodec.ERROR, downloader.getErrorMessage()); + } + } else { + logger.debug("No need for download"); + getJsonResponse() + .addKeyValues(JsonCodec.OUT, "File already downloaded, will not download again"); + } + + getJsonResponse() + .addKeyValues(JsonCodec.WebDriver.Downloader.FILE_FULL_PATH, + downloader.getDestinationFileFullPath().getAbsolutePath()); + + getJsonResponse() + .addKeyValues(JsonCodec.WebDriver.Downloader.FILE, + downloader.getDestinationFileFullPath().getName()); + + return getJsonResponse().getJson(); + } + + @Override + public boolean initialize() { + + try { + File + EdgeDriverExecutable = + new File(RuntimeConfig.getConfig().getEdgeDriver().getExecutablePath()); + File EdgeDriverHome = new File(RuntimeConfig.getConfig().getEdgeDriver().getDirectory()); + + if (!EdgeDriverHome.exists()) { + EdgeDriverHome.mkdir(); + } + + if (!EdgeDriverExecutable.exists()) { + systemAndLog("Downloading Edge Driver " + RuntimeConfig.getConfig().getEdgeDriver() + .getVersion()); + logger.info(execute().toString()); + } + + + } catch (NullPointerException error) { + printInitilizedFailure(); + logger.error(error); + return false; + } + + printInitilizedSuccessAndRegisterWithAPI(); + return true; + + } + + +} + diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllEdge.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllEdge.java new file mode 100644 index 00000000..4190d84b --- /dev/null +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/KillAllEdge.java @@ -0,0 +1,72 @@ +/** + * 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.tasks; + +import com.google.gson.JsonObject; +import com.groupon.seleniumgridextras.tasks.config.TaskDescriptions; + +public class KillAllEdge extends KillAllByName { + + public KillAllEdge() { + setEndpoint(TaskDescriptions.Endpoints.KILL_EDGE); + setDescription(TaskDescriptions.Description.KILL_EDGE); + JsonObject params = new JsonObject(); + setAcceptedParams(params); + setRequestType("GET"); + setResponseType("json"); + setClassname(this.getClass().getCanonicalName().toString()); + setCssClass(TaskDescriptions.UI.BTN_DANGER); + setButtonText(TaskDescriptions.UI.ButtonText.KILL_EDGE); + setEnabledInGui(true); + } + + @Override + public String getWindowsCommand() { + return super.getWindowsCommand("msedge.exe"); + } + + @Override + public String getLinuxCommand() { + return super.getLinuxCommand("msedge"); + } + + @Override + public String getMacCommand() { + return super.getMacCommand("msedge"); + } +} diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/config/TaskDescriptions.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/config/TaskDescriptions.java index f3772372..f0d96504 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/config/TaskDescriptions.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/tasks/config/TaskDescriptions.java @@ -8,6 +8,7 @@ public static class Endpoints { public static final String DOWNLOAD_GECKODRIVER = "/download_geckodriver"; public static final String DOWNLOAD_IEDRIVER = "/download_iedriver"; public static final String DOWNLOAD_WEBDRIVER = "/download_webdriver"; + public static final String DOWNLOAD_EDGEDRIVER = "/download_edgedriver"; public static final String DIR = "/dir"; public static final String CONFIG = "/config"; public static final String GET_FILE = "/get_file"; @@ -22,6 +23,7 @@ public static class Endpoints { public static final String KILL_FIREFOX = "/kill_firefox"; public static final String KILL_IE = "/kill_ie"; public static final String KILL_SAFARI = "/kill_safari"; + public static final String KILL_EDGE = "/kill_edge"; public static final String KILL_PID = "/kill_pid"; public static final String MOVE_MOUSE = "/move_mouse"; public static final String LOG_DELETE = "/log_delete"; @@ -58,6 +60,9 @@ public static class Description { String DOWNLOAD_IEDRIVER = "Downloads a version of IEDriver.exe to local machine"; public static final + String DOWNLOAD_EDGEDRIVER = + "Downloads a version of MSEDGEDriver to local machine"; + public static final String DOWNLOAD_WEBDRIVER = "Downloads a version of WebDriver jar to local machine"; public static final @@ -103,6 +108,12 @@ public static class Description { String KILL_SAFARI = "Executes os level kill command on all instance of Safari"; + + public static final + String + KILL_EDGE = + "Executes os level kill command on all instance of Edge"; + public static final String KILL_PID = "Kills a given process id"; public static final String LOG_DELETE = "Delete logs older than X Days. X is define in the config.json"; public static final @@ -160,6 +171,7 @@ public static class ButtonText { public static final String DOWNLOAD_GECKODRIVER = "Download Gecko-Driver"; public static final String DOWNLOAD_IEDRIVER = "Download IE-Driver"; public static final String DOWNLOAD_WEBDRIVER = "Download WebDriver"; + public static final String DOWNLOAD_EDGEDRIVER = "Download WebDriver"; public static final String DIR = "List Shared Dir"; public static final String CONFIG = "Get Config"; public static final String GET_FILE = "Get File"; @@ -174,6 +186,7 @@ public static class ButtonText { public static final String KILL_FIREFOX = "Kill all firefox"; public static final String KILL_IE = "Kill all IE"; public static final String KILL_SAFARI = "Kill all Safari"; + public static final String KILL_EDGE = "Kill all Edge"; public static final String KILL_PID = "Kill PID"; public static final String MOVE_MOUSE = "Move mouse"; public static final String NETSTAT = "netstat"; diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonCodec.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonCodec.java index f8df53d3..ac09928f 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonCodec.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/json/JsonCodec.java @@ -173,10 +173,12 @@ public static class WebDriver { public static final String OLD_CHROME_DRIVER = "old_chrome_driver"; public static final String OLD_GECKO_DRIVER = "old_gecko_driver"; public static final String OLD_IE_DRIVER = "old_ie_driver"; + public static final String OLD_EDGE_DRIVER = "old_ie_driver"; public static final String NEW_WEB_DRIVER_JAR = "new_web_driver_jar"; public static final String NEW_CHROME_DRIVER = "new_chrome_driver"; public static final String NEW_GECKO_DRIVER = "new_gecko_driver"; public static final String NEW_IE_DRIVER = "new_ie_driver"; + public static final String NEW_EDGE_DRIVER = "new_ie_driver"; public static class Grid { diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/SessionHistoryCallable.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/SessionHistoryCallable.java index 4db36d86..d6561c6e 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/SessionHistoryCallable.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/SessionHistoryCallable.java @@ -3,6 +3,7 @@ import com.google.common.base.Throwables; import com.groupon.seleniumgridextras.config.DefaultConfig; import com.groupon.seleniumgridextras.config.RuntimeConfig; +import com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy; import com.groupon.seleniumgridextras.loggers.SessionHistoryLog; import com.groupon.seleniumgridextras.tasks.config.TaskDescriptions; import com.groupon.seleniumgridextras.utilities.HttpUtility; @@ -48,10 +49,11 @@ public String call() throws Exception { protected String notifyNodeGridExtrasOfNewSession() { try { + int port = SetupTeardownProxy.getNodeExtrasPort(session); URIBuilder uri = new URIBuilder(); uri.setScheme("http"); uri.setHost(getSession().getSlot().getRemoteURL().getHost()); - uri.setPort(RuntimeConfig.getGridExtrasPort()); + uri.setPort(port); uri.setPath(TaskDescriptions.Endpoints.GRID_STATUS); if (getSession().getExternalKey() != null) { uri.addParameter(JsonCodec.WebDriver.Grid.NEW_SESSION_PARAM, getSession().getExternalKey().getKey()); @@ -80,7 +82,7 @@ protected String notifyHubGridExtrasOfNewSession() { sessionDetails.put(JsonCodec.WebDriver.Grid.INTERNAL_KEY, getSession().getInternalKey()); sessionDetails.put(JsonCodec.WebDriver.Grid.EXTERNAL_KEY, JsonCodec.WebDriver.Grid.NOT_YET_ASSIGNED); sessionDetails.put(JsonCodec.WebDriver.Grid.HOST, getSession().getSlot().getRemoteURL().getHost()); - sessionDetails.put(JsonCodec.WebDriver.Grid.PORT, String.valueOf(getSession().getSlot().getRemoteURL().getPort())); + sessionDetails.put(JsonCodec.WebDriver.Grid.PORT, SetupTeardownProxy.getNodeExtrasPort(session)); sessionDetails.put(JsonCodec.TIMESTAMP, TimeStampUtility.getTimestampAsString()); // sessionDetails.put(JsonCodec.WebDriver.Grid.REQUESTED_CAPABILITIES, getSession().getRequestedCapabilities()); diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/RemoteVideoRecordingControlCallable.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/RemoteVideoRecordingControlCallable.java index 9fabf957..1c4a1075 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/RemoteVideoRecordingControlCallable.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/RemoteVideoRecordingControlCallable.java @@ -111,6 +111,7 @@ protected boolean acquiredExternalKey() { protected String updateLastAction() { String m = RemoteVideoRecorderHelper.updateLastAction( this.session.getSlot().getRemoteURL().getHost(), + SetupTeardownProxy.getNodeExtrasPort(session), this.session.getExternalKey().getKey(), this.lastAction); @@ -121,6 +122,7 @@ protected String updateLastAction() { protected String stopVideo() { String m = RemoteVideoRecorderHelper.stopVideoRecording( this.session.getSlot().getRemoteURL().getHost(), + SetupTeardownProxy.getNodeExtrasPort(session), this.session.getExternalKey().getKey()); logger.debug(m); @@ -131,6 +133,7 @@ protected String stopVideo() { protected String startVideo() { return RemoteVideoRecorderHelper.startVideoRecording( this.session.getSlot().getRemoteURL().getHost(), + SetupTeardownProxy.getNodeExtrasPort(session), this.session.getExternalKey().getKey()); } diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/VideoDownloaderCallable.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/VideoDownloaderCallable.java index 4c046c6f..186b61d9 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/VideoDownloaderCallable.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/threads/video/VideoDownloaderCallable.java @@ -23,14 +23,16 @@ public class VideoDownloaderCallable implements Callable { private static Logger logger = Logger.getLogger(VideoDownloaderCallable.class); private final String session; private final String host; + private final int nodePort; private final URI uri; private final int ATTEMPTS_TO_DOWNLOAD = 5; private final int TIME_TO_WAIT_BETWEEN_ATTEMPTS = 30000; - public VideoDownloaderCallable(String session, String host) { + public VideoDownloaderCallable(String session, String host, int nodePort) { logger.info(String.format("New instance for session: %s host: %s", session, host)); this.session = session; this.host = host; + this.nodePort = nodePort; this.uri = buildVideoStatusUri(); } @@ -187,7 +189,7 @@ protected URI buildVideoStatusUri() { URIBuilder builder = new URIBuilder(); builder.setScheme("http"); builder.setHost(this.host); - builder.setPort(RuntimeConfig.getGridExtrasPort()); + builder.setPort(this.nodePort); builder.setPath(TaskDescriptions.Endpoints.VIDEO); try { diff --git a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/videorecording/RemoteVideoRecorderHelper.java b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/videorecording/RemoteVideoRecorderHelper.java index 46814445..3c67878d 100644 --- a/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/videorecording/RemoteVideoRecorderHelper.java +++ b/SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/videorecording/RemoteVideoRecorderHelper.java @@ -17,12 +17,12 @@ public class RemoteVideoRecorderHelper { private static Logger logger = Logger.getLogger(RemoteVideoRecorderHelper.class); - public static String startVideoRecording(String host, String session) { + public static String startVideoRecording(String host, int port, String session) { URIBuilder builder = new URIBuilder(); builder.setScheme("http"); builder.setHost(host); - builder.setPort(RuntimeConfig.getGridExtrasPort()); + builder.setPort(port); builder.setPath(TaskDescriptions.Endpoints.VIDEO); Map params = getBlankParams(session, JsonCodec.Video.START); @@ -33,7 +33,7 @@ public static String startVideoRecording(String host, String session) { URI uri; String errorMessage = String.format("Error building URI for host: %s, port: %s, session: %s, action: %s, params: %s", host, - RuntimeConfig.getGridExtrasPort(), + port, session, JsonCodec.Video.START, params.toString()); @@ -51,12 +51,12 @@ public static String startVideoRecording(String host, String session) { } - public static String stopVideoRecording(String host, String session) { + public static String stopVideoRecording(String host, int port, String session) { URIBuilder builder = new URIBuilder(); builder.setScheme("http"); builder.setHost(host); - builder.setPort(RuntimeConfig.getGridExtrasPort()); + builder.setPort(port); builder.setPath(TaskDescriptions.Endpoints.VIDEO); Map params = getBlankParams(session, JsonCodec.Video.STOP); @@ -66,7 +66,7 @@ public static String stopVideoRecording(String host, String session) { URI uri; String errorMessage = String.format("Error building URI for host: %s, port: %s, session: %s, action: %s, params: %s", host, - RuntimeConfig.getGridExtrasPort(), + port, session, JsonCodec.Video.STOP, params.toString()); @@ -84,11 +84,11 @@ public static String stopVideoRecording(String host, String session) { } - public static String updateLastAction(String host, String session, String action) { + public static String updateLastAction(String host, int port, String session, String action) { URIBuilder builder = new URIBuilder(); builder.setScheme("http"); builder.setHost(host); - builder.setPort(RuntimeConfig.getGridExtrasPort()); + builder.setPort(port); builder.setPath(TaskDescriptions.Endpoints.VIDEO); Map params = getBlankParams(session, JsonCodec.Video.HEARTBEAT); @@ -100,7 +100,7 @@ public static String updateLastAction(String host, String session, String action URI uri; String errorMessage = String.format("Error building URI for host: %s, port: %s, session: %s, action: %s, params: %s", host, - RuntimeConfig.getGridExtrasPort(), + port, session, JsonCodec.Video.HEARTBEAT, params.toString()); diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/KillAllEdgeTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/KillAllEdgeTest.java new file mode 100644 index 00000000..b68876fa --- /dev/null +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/KillAllEdgeTest.java @@ -0,0 +1,73 @@ +/** + * 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; + + +import com.groupon.seleniumgridextras.tasks.ExecuteOSTask; +import com.groupon.seleniumgridextras.tasks.KillAllChrome; +import com.groupon.seleniumgridextras.tasks.KillAllEdge; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class KillAllEdgeTest { + + private ExecuteOSTask task; + private String windowsCommand; + private String linuxCommnad; + private String macCommand; + + @Before + public void setUp() throws Exception { + task = new KillAllEdge(); + windowsCommand = "taskkill -F -IM msedge.exe"; + linuxCommnad = "killall -v -m msedge"; + macCommand = linuxCommnad; + } + + @Test + public void testGetDescription() throws Exception { + assertEquals("Executes os level kill command on all instance of Edge", task.getDescription()); + } + + @Test + public void testGetEndpoint() throws Exception { + assertEquals("/kill_edge", task.getEndpoint()); + } +} diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfigTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfigTest.java index 4e947512..a78ae4f0 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfigTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/FirstTimeRunConfigTest.java @@ -1,6 +1,24 @@ package com.groupon.seleniumgridextras.config; +import com.groupon.seleniumgridextras.browser.BrowserVersionDetector; +import org.junit.Test; + public class FirstTimeRunConfigTest { + @Test + public void testGuessBrowserVersion() throws Exception { + + Config userInput = Config.initilizedFromUserInput(); + + FirstTimeRunConfig.customiseConfig(userInput); + + BrowserVersionDetector.guessBrowserVersion("firefox"); + BrowserVersionDetector.guessBrowserVersion("chrome"); + BrowserVersionDetector.guessBrowserVersion("Edge"); + BrowserVersionDetector.guessBrowserVersion("MicrosoftEdge"); + BrowserVersionDetector.guessBrowserVersion("internetexplorer"); + BrowserVersionDetector.guessBrowserVersion("internet explorer"); + + } } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/GridNodeTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/GridNodeTest.java index 32fb2d19..9265b5bf 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/GridNodeTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/GridNodeTest.java @@ -108,10 +108,11 @@ public void testCustomConfigurationFromFile() throws Exception { assertEquals(expectedCapabilities, nodeFromFile.getCapabilities()); String actual = JsonParserWrapper.prettyPrintString(nodeFromFile); - assertTrue(actual.contains("\"custom\": {\n" + + assertTrue("ACTUAL : \n" + actual, actual.contains("\"custom\": {\n" + " \"customString\": \"custom\",\n" + " \"customInt\": 1,\n" + - " \"customBoolean\": false\n" + + " \"customBoolean\": false,\n" + + " \"grid_extras_port\": 3000\n" + " }")); } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/capabilities/CapabilityTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/capabilities/CapabilityTest.java index a1a4d00b..8101152e 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/capabilities/CapabilityTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/config/capabilities/CapabilityTest.java @@ -21,6 +21,7 @@ public void getCapabilitiesFromList() throws Exception { Capability iphone = Capability.getCapabilityFor("iPhone"); Capability ipad = Capability.getCapabilityFor("iPad"); Capability phantomjs = Capability.getCapabilityFor("phantomjs"); + Capability msedge = Capability.getCapabilityFor("MicrosoftEdge"); assertTrue(firefox instanceof Firefox); assertTrue(ie instanceof InternetExplorer); @@ -32,6 +33,7 @@ public void getCapabilitiesFromList() throws Exception { assertTrue(iphone instanceof IPhone); assertTrue(ipad instanceof IPad); assertTrue(phantomjs instanceof PhantomJs); + assertTrue(msedge instanceof Edge); } @@ -47,6 +49,7 @@ public void testGetWDStyleName() throws Exception { assertEquals("browser", Capability.getSupportedCapabilities().get(Browser.class)); assertEquals("iPhone", Capability.getSupportedCapabilities().get(IPhone.class)); assertEquals("iPad", Capability.getSupportedCapabilities().get(IPad.class)); + assertEquals("MicrosoftEdge", Capability.getSupportedCapabilities().get(Edge.class)); } @Test @@ -72,6 +75,8 @@ public void testGetCorrectWebDriverClass() throws Exception { Capability.getCapabilityFor("iPad").getWebDriverClass()); assertEquals("org.openqa.selenium.phantomjs.PhantomJSDriver", Capability.getCapabilityFor("phantomjs").getWebDriverClass()); + assertEquals("microsoft.edge.seleniumtools.edgeDriver", + Capability.getCapabilityFor("MicrosoftEdge").getWebDriverClass()); } } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/ChromeDriverDownloaderTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/ChromeDriverDownloaderTest.java index 7bd9be0f..7abeebcd 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/ChromeDriverDownloaderTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/ChromeDriverDownloaderTest.java @@ -3,6 +3,8 @@ import com.groupon.seleniumgridextras.config.Config; import com.groupon.seleniumgridextras.config.RuntimeConfig; +import com.groupon.seleniumgridextras.downloader.webdriverreleasemanager.WebDriverReleaseManager; +import com.groupon.seleniumgridextras.utilities.json.JsonCodec; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -53,8 +55,15 @@ public void testSetDestinationDir() throws Exception { @Test public void testSetBitVersion() throws Exception { - downloader.setBitVersion("64"); - assertEquals("64", downloader.getBitVersion()); +/* downloader.setBitVersion("64"); + assertEquals("64", downloader.getBitVersion());*/ + + WebDriverReleaseManager manager = RuntimeConfig.getReleaseManager(); + String versionOfChromeDriver = manager.getChromeDriverLatestVersion().getPrettyPrintVersion("."); + String bitOfEdgeDriver = JsonCodec.WebDriver.Downloader.BIT_64; + String[] bitVersionsChromeDriver = ChromeDriverDownloader.getBitArchitecturesForVersion(versionOfChromeDriver); + System.out.println("\nWARNING: We were unable to find the correct bit of EdgeDriver for this OS and EdgeDriver version: " + versionOfChromeDriver + " so will default to '32' please update this to be more accurate, or grid may not function properly\n"); + } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloaderTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloaderTest.java new file mode 100644 index 00000000..d7ced935 --- /dev/null +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/EdgeDriverDownloaderTest.java @@ -0,0 +1,73 @@ +package com.groupon.seleniumgridextras.downloader; + +import com.groupon.seleniumgridextras.config.Config; +import com.groupon.seleniumgridextras.config.RuntimeConfig; +import com.groupon.seleniumgridextras.downloader.webdriverreleasemanager.WebDriverReleaseManager; +import com.groupon.seleniumgridextras.utilities.json.JsonCodec; +import org.apache.commons.lang3.StringUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; + +import static org.junit.Assert.assertEquals; + +public class EdgeDriverDownloaderTest { + + private EdgeDriverDownloader downloader; + private final String downloadDir = "/tmp/download_edge_driver_test"; + + @Before + public void setUp() throws Exception { + RuntimeConfig.setConfigFile("edge_download_test.json"); + Config config = new Config(); + + config.getEdgeDriver().setDirectory(downloadDir); + config.writeToDisk(RuntimeConfig.getConfigFile()); + RuntimeConfig.load(); + downloader = new EdgeDriverDownloader("86.0.598.0", "32"); + } + + @After + public void tearDown() throws Exception { + new File(RuntimeConfig.getConfigFile()).delete(); + new File(RuntimeConfig.getConfigFile() + ".example").delete(); + new File(downloader.getDestinationDir()).delete(); + } + + @Test + public void testSetSourceURL() throws Exception { + downloader.setSourceURL("google.com"); + assertEquals("google.com", downloader.getSourceURL()); + + } + + @Test + public void testSetDestinationDir() throws Exception { + assertEquals(downloadDir, downloader.getDestinationDir()); + downloader.setDestinationDir("temp"); + assertEquals("temp", downloader.getDestinationDir()); + } + + + @Test + public void testSetBitVersion() throws Exception { + downloader.setBitVersion("64"); + assertEquals("64", downloader.getBitVersion()); + } + + + @Test + public void testSetVersion() throws Exception { + downloader.setVersion("5"); + assertEquals("5", downloader.getVersion()); + } + + @Test + public void testGetOSNames() throws Exception { + assertEquals("mac", downloader.getMacName()); + assertEquals("win", downloader.getWindowsName()); + assertEquals("linux", downloader.getLinuxName()); + } +} diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GeckoDriverDownloaderTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GeckoDriverDownloaderTest.java index 7f9a7405..906d16f0 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GeckoDriverDownloaderTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GeckoDriverDownloaderTest.java @@ -17,7 +17,7 @@ public class GeckoDriverDownloaderTest { private GeckoDriverDownloader downloader; private final String downloadDir = "/tmp/download_gecko_driver_test"; private File testDir = new File("gecko_downloader_test"); - private final String VERSION = "0.10.0"; + private final String VERSION = "0.29.0"; @Before public void setUp() throws Exception { diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GridExtrasDownloaderTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GridExtrasDownloaderTest.java index e69b6a01..e646f0d1 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GridExtrasDownloaderTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/GridExtrasDownloaderTest.java @@ -22,7 +22,7 @@ public class GridExtrasDownloaderTest { public static final String EXPECTED_VERSION = "1.10.1"; public static final String EXPECTED_1101_DOWNLOAD_URL = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/1.10.1/SeleniumGridExtras-1.10.1-SNAPSHOT-jar-with-dependencies.jar"; - public static final String GRID_EXTRAS_RELEASE_API_URL = "https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases"; + public static final String GRID_EXTRAS_RELEASE_API_URL = "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases"; public static final String EXPECTED_171_URL = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/v1.7.1/SeleniumGridExtras-1.7.1-SNAPSHOT-jar-with-dependencies.jar"; public static final String EXPECTED_JAR_NAME = "SeleniumGridExtras-1.10.1-SNAPSHOT-jar-with-dependencies.jar"; public static final int GRID_EXTRAS_AUTO_UPDATE_CHECK_INTERVAL = 2000; @@ -86,8 +86,8 @@ public void testGetCachedReleaseList() throws Exception { long msRange = TimeStampUtility.timestampInMs() - downloader.getCachedReleaseResponseFile().lastModified(); assertTrue(msRange < 10000); //Make sure that file created is no older than 10 seconds - System.out.println("INITIAL RESPONSE : " + initialResponse); - System.out.println("downloader.getCachedReleaseList() : " + downloader.getCachedReleaseList()); + // System.out.println("INITIAL RESPONSE : " + initialResponse); + // System.out.println("downloader.getCachedReleaseList() : " + downloader.getCachedReleaseList()); assertEquals(initialResponse, downloader.getCachedReleaseList()); Thread.sleep(5000); @@ -95,8 +95,8 @@ public void testGetCachedReleaseList() throws Exception { //But the file gets re-written assertEquals(initialResponse, downloader.getCachedReleaseList()); - System.out.println("INITIAL RESPONSE : " + initialResponse); - System.out.println("downloader.getCachedReleaseList() : " + downloader.getCachedReleaseList()); + // System.out.println("INITIAL RESPONSE : " + initialResponse); + // System.out.println("downloader.getCachedReleaseList() : " + downloader.getCachedReleaseList()); long msRange2 = TimeStampUtility.timestampInMs() - downloader.getCachedReleaseResponseFile().lastModified(); assertTrue(msRange2 < 2000); //Make sure that file created is no older than 2 seconds } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java index a0319a59..e6b0f537 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/downloader/WebDriverReleaseManagerTest.java @@ -20,7 +20,8 @@ public void setUp() throws Exception { URL webDriverAndIEDriverURL = ClassLoader.getSystemResource("fixtures/selenium_release_manifest.xml"); URL chromeDriverVersionURL = ClassLoader.getSystemResource("fixtures/selenium_release_version.txt"); URL marionetteDriverVersionURL = ClassLoader.getSystemResource("fixtures/selenium_release_version.txt"); - releaseManager = new WebDriverReleaseManager(webDriverAndIEDriverURL, chromeDriverVersionURL, marionetteDriverVersionURL); + URL edgeDriverVersionURL = ClassLoader.getSystemResource("fixtures/selenium_release_version.txt"); + releaseManager = new WebDriverReleaseManager(webDriverAndIEDriverURL, chromeDriverVersionURL, marionetteDriverVersionURL , edgeDriverVersionURL); } @Test @@ -41,22 +42,26 @@ public void testGetVersionsFromLiveSource() throws Exception { String wdManifest = "http://selenium-release.storage.googleapis.com/"; String chromeManifest = "http://chromedriver.storage.googleapis.com/LATEST_RELEASE"; String marionetteManifest = "http://chromedriver.storage.googleapis.com/LATEST_RELEASE"; + String edgeManifest = "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/LATEST_STABLE"; WebDriverReleaseManager manager = - new WebDriverReleaseManager(new URL(wdManifest), new URL(chromeManifest), new URL(marionetteManifest)); + new WebDriverReleaseManager(new URL(wdManifest), new URL(chromeManifest), new URL(marionetteManifest) , new URL(edgeManifest)); assertNotEquals(null, manager.getWedriverLatestVersion().getPrettyPrintVersion(".")); assertNotEquals(null, manager.getIeDriverLatestVersion().getPrettyPrintVersion(".")); assertNotEquals(null, manager.getChromeDriverLatestVersion().getPrettyPrintVersion(".")); + assertNotEquals(null, manager.getEdgeDriverLatestVersion().getPrettyPrintVersion(".")); assertEquals("selenium-server-standalone", manager.getWedriverLatestVersion().getName()); assertEquals("IEDriverServer", manager.getIeDriverLatestVersion().getName()); assertEquals("chromedriver", manager.getChromeDriverLatestVersion().getName()); + assertEquals("edgedriver", manager.getChromeDriverLatestVersion().getName()); assertNotEquals(null, manager.getWedriverLatestVersion().getRelativePath()); assertNotEquals(null, manager.getIeDriverLatestVersion().getRelativePath()); assertNotEquals(null, manager.getChromeDriverLatestVersion().getRelativePath()); + assertNotEquals(null, manager.getEdgeDriverLatestVersion().getRelativePath()); } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/GridStarterTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/GridStarterTest.java index f8d293c1..c2cd40d3 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/GridStarterTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/GridStarterTest.java @@ -234,8 +234,10 @@ public void testBuildBackgroundStartCommand() throws Exception { @Test public void testEdgeDriverDString() throws Exception { Config config = new Config(); + config.getChromeDriver().setDirectory("/tmp/webdriver/msedgedriver"); + String path = GridStarter.getEdgeDriverExecutionPathParam(config); assertEquals("-Dwebdriver.edge.driver=\"C:\\Program Files (x86)\\Microsoft Web Driver\\MicrosoftWebDriver.exe\"", - GridStarter.getEdgeDriverExecutionPathParam(config)); + path ); } @Test @@ -243,7 +245,8 @@ public void testChromeDriverDString() throws Exception { Config config = new Config(); config.getChromeDriver().setDirectory("/tmp/webdriver/chromedriver"); if (RuntimeConfig.getOS().isWindows()) { - assertTrue(GridStarter.getChromeDriverExecutionPathParam(config).contains("-Dwebdriver.chrome.driver=\\tmp\\webdriver\\chromedriver\\chromedriver_")); + String path = GridStarter.getChromeDriverExecutionPathParam(config); + assertTrue(path.contains("-Dwebdriver.chrome.driver=\\tmp\\webdriver\\chromedriver\\chromedriver_")); } else { assertTrue(GridStarter.getChromeDriverExecutionPathParam(config).contains("-Dwebdriver.chrome.driver=/tmp/webdriver/chromedriver/chromedriver_")); } diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/SetupTeardownProxyTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/SetupTeardownProxyTest.java index 4bf80979..78edc39d 100644 --- a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/SetupTeardownProxyTest.java +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/grid/proxies/sessions/threads/SetupTeardownProxyTest.java @@ -7,6 +7,8 @@ import com.groupon.seleniumgridextras.config.RuntimeConfig; import com.groupon.seleniumgridextras.config.capabilities.BrowserType; import com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy; +import com.groupon.seleniumgridextras.loggers.SessionHistoryLog; + import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Assert; @@ -19,6 +21,8 @@ import java.io.File; import java.net.URL; +import java.util.HashMap; +import java.util.Map; import java.util.UUID; import java.util.concurrent.Future; @@ -85,6 +89,12 @@ public void testLogSessionWithSessionHistoryEnabled() throws Exception { Assert.assertTrue(!Strings.isNullOrEmpty(result)); File sessionLogDir = DefaultConfig.SESSION_LOG_DIRECTORY; + SessionHistoryLog.setOutputDir(sessionLogDir); + Map sessionInfo = new HashMap(); + sessionInfo.put("id", "123456"); + sessionInfo.put("stuff", "stuff"); + SessionHistoryLog.newSession("nodez", sessionInfo); + Assert.assertTrue("Expect the session log directory to exist!", sessionLogDir.exists()); Assert.assertTrue("Expect the session log directory to be a directory!", sessionLogDir.isDirectory()); Assert.assertTrue("Expect the session log directory to have a file!", sessionLogDir.list().length > 0); diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDriversTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDriversTest.java new file mode 100644 index 00000000..af2be514 --- /dev/null +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/AutoUpgradeDriversTest.java @@ -0,0 +1,30 @@ +package com.groupon.seleniumgridextras.tasks; + +import com.groupon.seleniumgridextras.config.Config; +import com.groupon.seleniumgridextras.config.DefaultConfig; +import com.groupon.seleniumgridextras.config.RuntimeConfig; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class AutoUpgradeDriversTest { + + public AutoUpgradeDrivers task; + private String downloadDir = "/tmp/update_driver_test"; + + @Before + public void setUp() throws Exception { + RuntimeConfig.setConfigFile("update_driver_test.json"); + Config config = DefaultConfig.getDefaultConfig(); + config.getChromeDriver().setDirectory(downloadDir); + config.writeToDisk(RuntimeConfig.getConfigFile()); + RuntimeConfig.load(); + task = new AutoUpgradeDrivers(); + } + + @Test + public void testAutoUpdate() throws Exception { + task.execute(); + } +} \ No newline at end of file diff --git a/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriverTest.java b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriverTest.java new file mode 100644 index 00000000..54729e5e --- /dev/null +++ b/SeleniumGridExtras/src/test/java/com/groupon/seleniumgridextras/tasks/DownloadEdgeDriverTest.java @@ -0,0 +1,190 @@ +/** + * 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.tasks; + +import com.groupon.seleniumgridextras.config.Config; +import com.groupon.seleniumgridextras.config.DefaultConfig; +import com.groupon.seleniumgridextras.config.RuntimeConfig; +import com.groupon.seleniumgridextras.utilities.json.JsonParserWrapper; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.util.ArrayList; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +public class DownloadEdgeDriverTest { + + public DownloadEdgeDriver task; + private String downloadDir = "/tmp/edge_downloader_test"; + + @Before + public void setUp() throws Exception { + deleteDownloadDir(); + RuntimeConfig.setConfigFile("download_edge_test.json"); + Config config = DefaultConfig.getDefaultConfig(); + + config.getEdgeDriver().setDirectory(downloadDir); + + config.writeToDisk(RuntimeConfig.getConfigFile()); + + RuntimeConfig.load(); + task = new DownloadEdgeDriver(); + } + + @After + public void tearDown() throws Exception { + File config = new File(RuntimeConfig.getConfigFile()); + config.delete(); + new File(RuntimeConfig.getConfigFile() + ".example").delete(); + deleteDownloadDir(); + } + + @Test + public void testGetEndpoint() throws Exception { + assertEquals("/download_edgedriver", task.getEndpoint()); + } + + @Test + public void testGetDescription() throws Exception { + assertEquals("Downloads a version of MSEDGEDriver to local machine", task.getDescription()); + } + + @Test + public void testGetJsonResponse() throws Exception { + assertEquals( + "{\"exit_code\":0,\"out\":[],\"error\":[],\"root_dir\":[\"" + downloadDir + + "\"],\"file\":[\"\"],\"file_full_path\":[\"" + + "\"],\"source_url\":[\"\"]}", + task.getJsonResponse().toString()); + } + + @Test + public void testGetAcceptedParams() throws Exception { + assertEquals("Version of EdgeDriver to download, such as 2.6", + task.getAcceptedParams().get("version").getAsString()); + + assertEquals("Bit Version of EdgeDriver 32/64 - (default: 32)", + task.getAcceptedParams().get("bit").getAsString()); + + assertEquals(2, task.getAcceptedParams().entrySet().size()); + } + + @Test + public void testExecute() throws Exception { + + String os = getOS(); + // default setting from configuration + String bit = "32"; + String version = "86.0.598.0"; + + Map firstExec = JsonParserWrapper.toHashMap(task.execute(version)); + + File expectedFile = new File(RuntimeConfig.getConfig().getEdgeDriver().getExecutablePath()); + + assertEquals(0.0, firstExec.get("exit_code")); + assertEquals(expectedFile.getName(), ((ArrayList) firstExec.get("file")).get(0)); + assertEquals(0, ((ArrayList) firstExec.get("error")).size()); + assertEquals(0, ((ArrayList) firstExec.get("out")).size()); + assertEquals(downloadDir, ((ArrayList) firstExec.get("root_dir")).get(0)); + assertEquals(expectedFile.getAbsolutePath(), + ((ArrayList) firstExec.get("file_full_path")).get(0)); + assertEquals("https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/" + version + "/edgedriver_" + os + bit + ".zip", + ((ArrayList) firstExec.get("source_url")).get(0)); + + Map secondExec = JsonParserWrapper.toHashMap(task.execute(version)); + + assertEquals(0.0, secondExec.get("exit_code")); + assertEquals(0, ((ArrayList) secondExec.get("error")).size()); + assertEquals("File already downloaded, will not download again", + ((ArrayList) secondExec.get("out")).get(0)); + + assertFalse(secondExec.containsKey("root_dir")); + assertFalse(secondExec.containsKey("source_url")); + + assertEquals(expectedFile.getAbsolutePath(), + ((ArrayList) firstExec.get("file_full_path")).get(0)); + } + + @Test + public void testCustomExecute() throws Exception { + String os = getOS(); + String bit = "64"; + String version = "86.0.598.0"; + RuntimeConfig.getConfig().getEdgeDriver().setBit(bit); + + DownloadEdgeDriver customSettingTask = new DownloadEdgeDriver(); + + Map firstExec = JsonParserWrapper.toHashMap(customSettingTask.execute(version)); + assertEquals("https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver/" + version + "/edgedriver_" + os + bit + ".zip", + ((ArrayList) firstExec.get("source_url")).get(0)); + + } + + private String getOS() { + if (RuntimeConfig.getOS().isWindows()) { + return "win"; + } else if (RuntimeConfig.getOS().isMac()) { + return "mac"; + } else { + return "linux"; + } + } + + private void deleteDownloadDir() { + + File dir = new File(downloadDir); + + if (dir.exists()) { + if (dir.list().length != 0) { + for (String file : dir.list()) { + new File(dir, file).delete(); + } + } + + dir.delete(); + + } + + } + +} diff --git a/SeleniumGridExtras/src/test/resources/fixtures/configs/additional_classpath.json b/SeleniumGridExtras/src/test/resources/fixtures/configs/additional_classpath.json index 20a987b3..4302c9a1 100644 --- a/SeleniumGridExtras/src/test/resources/fixtures/configs/additional_classpath.json +++ b/SeleniumGridExtras/src/test/resources/fixtures/configs/additional_classpath.json @@ -36,7 +36,7 @@ "height": "768", "lower_third_font_color": "255,255,255,255" }, - "grid_extras_release_url": "https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases", + "grid_extras_release_url": "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases", "hub_additional_classpath": [ "/opt/selenium/prioritizer.jar", "/opt/selenium/lib/capabilitymatcher.jar" @@ -61,6 +61,7 @@ "com.groupon.seleniumgridextras.tasks.KillAllFirefox", "com.groupon.seleniumgridextras.tasks.KillAllChrome", "com.groupon.seleniumgridextras.tasks.KillAllSafari", + "com.groupon.seleniumgridextras.tasks.KillAllEdge", "com.groupon.seleniumgridextras.tasks.GetProcesses", "com.groupon.seleniumgridextras.tasks.KillPid", "com.groupon.seleniumgridextras.tasks.Netstat", @@ -82,6 +83,7 @@ "com.groupon.seleniumgridextras.tasks.DownloadWebdriver", "com.groupon.seleniumgridextras.tasks.DownloadIEDriver", "com.groupon.seleniumgridextras.tasks.DownloadChromeDriver", + "com.groupon.seleniumgridextras.tasks.DownloadEdgeDriver", "com.groupon.seleniumgridextras.tasks.SessionHistory", "com.groupon.seleniumgridextras.tasks.UpgradeGridExtrasTask" ], @@ -95,6 +97,11 @@ "directory": "/tmp/webdriver/chromedriver", "version": "2.10" }, + "edgedriver": { + "bit": "32", + "directory": "/tmp/webdriver/edgedriver", + "version": "86.0.598.0" + }, "disabled_modules": [ "com.groupon.seleniumgridextras.tasks.GetFile" ], diff --git a/SeleniumGridExtras/update_driver_test.json b/SeleniumGridExtras/update_driver_test.json new file mode 100644 index 00000000..8b551768 --- /dev/null +++ b/SeleniumGridExtras/update_driver_test.json @@ -0,0 +1,131 @@ +{ + "theConfigMap": { + "auto_update_browser_versions": "", + "log_maximum_size": "20000000", + "iedriver": { + "bit": "Win32", + "directory": "\\tmp\\webdriver\\iedriver", + "version": "3.141.59" + }, + "default_role": "hub", + "auto_update_drivers": "1", + "html_render_options": { + "html_footer_partial": "/footer_partial.html", + "main_js_file": "/bootstrap.3.2.0.min.js", + "primary_css_file_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css", + "html_header_file": "/header_partial.html", + "main_template": "/jumbotron-narrow.css", + "primary_css_file": "/bootstrap.3.2.0.min.css", + "main_js_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js", + "jquery_file": "/jquery.1.11.1.min.js", + "jquery_fallback": "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", + "html_nav_bar": "/nav_bar_partial.html", + "main_template_fallback": "http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" + }, + "http_request_timeout": 60000.0, + "node_additional_classpath": [], + "video_recording_options": { + "frameSeconds": "1", + "frames": "5", + "videos_to_keep": "40", + "lower_third_background_color": "0,0,0,200", + "idle_video_timeout": "120", + "width": "1024", + "video_output_dir": "video_output", + "title_frame_font_color": "129,182,64,128", + "record_test_videos": "true", + "height": "768", + "lower_third_font_color": "255,255,255,255" + }, + "grid_extras_release_url": "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases", + "hub_additional_classpath": [], + "geckodriver": { + "directory": "\\tmp\\webdriver\\geckodriver", + "version": "0.10.0" + }, + "msedgedriver": { + "bit": "32", + "directory": "\\tmp\\webdriver\\msedgedriver", + "version": "88.0.705.53" + }, + "reboot_after_sessions": "10", + "expose_directory": "shared", + "tear_down": [ + "com.groupon.seleniumgridextras.tasks.MoveMouse" + ], + "webdriver": { + "directory": "\\tmp\\webdriver", + "version": "3.141.59" + }, + "active_modules": [ + "com.groupon.seleniumgridextras.tasks.DeleteOldLogsTask", + "com.groupon.seleniumgridextras.tasks.Setup", + "com.groupon.seleniumgridextras.tasks.Teardown", + "com.groupon.seleniumgridextras.tasks.MoveMouse", + "com.groupon.seleniumgridextras.tasks.RebootNode", + "com.groupon.seleniumgridextras.tasks.VideoRecorder", + "com.groupon.seleniumgridextras.tasks.KillAllIE", + "com.groupon.seleniumgridextras.tasks.KillAllFirefox", + "com.groupon.seleniumgridextras.tasks.KillAllChrome", + "com.groupon.seleniumgridextras.tasks.KillAllEdge", + "com.groupon.seleniumgridextras.tasks.KillAllSafari", + "com.groupon.seleniumgridextras.tasks.SetAutoLogonUser", + "com.groupon.seleniumgridextras.tasks.GetProcesses", + "com.groupon.seleniumgridextras.tasks.KillPid", + "com.groupon.seleniumgridextras.tasks.Netstat", + "com.groupon.seleniumgridextras.tasks.Screenshot", + "com.groupon.seleniumgridextras.tasks.ExposeDirectory", + "com.groupon.seleniumgridextras.tasks.StartGrid", + "com.groupon.seleniumgridextras.tasks.GetInfoForPort", + "com.groupon.seleniumgridextras.tasks.GridStatus", + "com.groupon.seleniumgridextras.tasks.KillAllByName", + "com.groupon.seleniumgridextras.tasks.StopGrid", + "com.groupon.seleniumgridextras.tasks.GetConfig", + "com.groupon.seleniumgridextras.tasks.StopGridExtras", + "com.groupon.seleniumgridextras.tasks.IEProtectedMode", + "com.groupon.seleniumgridextras.tasks.IEMixedContent", + "com.groupon.seleniumgridextras.tasks.Resolution", + "com.groupon.seleniumgridextras.tasks.SystemInfo", + "com.groupon.seleniumgridextras.tasks.GetNodeConfig", + "com.groupon.seleniumgridextras.tasks.UpdateNodeConfig", + "com.groupon.seleniumgridextras.tasks.AutoUpgradeDrivers", + "com.groupon.seleniumgridextras.tasks.DownloadWebdriver", + "com.groupon.seleniumgridextras.tasks.DownloadIEDriver", + "com.groupon.seleniumgridextras.tasks.DownloadChromeDriver", + "com.groupon.seleniumgridextras.tasks.DownloadGeckoDriver", + "com.groupon.seleniumgridextras.tasks.DownloadEdgeDriver", + "com.groupon.seleniumgridextras.tasks.SessionHistory", + "com.groupon.seleniumgridextras.tasks.UpgradeGridExtrasTask" + ], + "hub_config_files": [], + "config_puller_http_timeout": 5000.0, + "auto_start_hub": "0", + "unregisterNodeDuringReboot": "true", + "chromedriver": { + "bit": "32", + "directory": "/tmp/update_driver_test", + "version": "88.0.4324.96" + }, + "disabled_modules": [ + "com.groupon.seleniumgridextras.tasks.GetFile" + ], + "grid_extras_auto_update_check_interval": "86400000", + "auto_start_node": "1", + "hub_config": { + "role": "hub", + "port": "4444", + "servlets": "com.groupon.seleniumgridextras.grid.servlets.ProxyStatusJsonServlet", + "host": "192.168.0.102" + }, + "log_maximum_age_ms": 8.64E8, + "grid_extras_port": 3000.0, + "grid": {}, + "setup": [ + "com.groupon.seleniumgridextras.tasks.MoveMouse" + ], + "grid_jvm_options": {}, + "node_config_files": [], + "grid_extras_jvm_options": {}, + "enable_session_history": "1" + } +} \ No newline at end of file diff --git a/SeleniumGridExtras/update_driver_test.json.example b/SeleniumGridExtras/update_driver_test.json.example new file mode 100644 index 00000000..68384bbf --- /dev/null +++ b/SeleniumGridExtras/update_driver_test.json.example @@ -0,0 +1,131 @@ +{ + "theConfigMap": { + "auto_update_browser_versions": "", + "log_maximum_size": "20000000", + "iedriver": { + "bit": "Win32", + "directory": "\\tmp\\webdriver\\iedriver", + "version": "2.53.1" + }, + "default_role": "hub", + "auto_update_drivers": "1", + "html_render_options": { + "html_footer_partial": "/footer_partial.html", + "main_js_file": "/bootstrap.3.2.0.min.js", + "primary_css_file_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css", + "html_header_file": "/header_partial.html", + "main_template": "/jumbotron-narrow.css", + "primary_css_file": "/bootstrap.3.2.0.min.css", + "main_js_fallback": "https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js", + "jquery_file": "/jquery.1.11.1.min.js", + "jquery_fallback": "https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js", + "html_nav_bar": "/nav_bar_partial.html", + "main_template_fallback": "http://getbootstrap.com/examples/jumbotron-narrow/jumbotron-narrow.css" + }, + "http_request_timeout": 60000.0, + "node_additional_classpath": [], + "video_recording_options": { + "frameSeconds": "1", + "frames": "5", + "videos_to_keep": "40", + "lower_third_background_color": "0,0,0,200", + "idle_video_timeout": "120", + "width": "1024", + "video_output_dir": "video_output", + "title_frame_font_color": "129,182,64,128", + "record_test_videos": "true", + "height": "768", + "lower_third_font_color": "255,255,255,255" + }, + "grid_extras_release_url": "https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases", + "hub_additional_classpath": [], + "geckodriver": { + "directory": "\\tmp\\webdriver\\geckodriver", + "version": "0.10.0" + }, + "msedgedriver": { + "bit": "32", + "directory": "\\tmp\\webdriver\\msedgedriver", + "version": "86.0.622.38" + }, + "reboot_after_sessions": "10", + "expose_directory": "shared", + "tear_down": [ + "com.groupon.seleniumgridextras.tasks.MoveMouse" + ], + "webdriver": { + "directory": "\\tmp\\webdriver", + "version": "2.53.0" + }, + "active_modules": [ + "com.groupon.seleniumgridextras.tasks.DeleteOldLogsTask", + "com.groupon.seleniumgridextras.tasks.Setup", + "com.groupon.seleniumgridextras.tasks.Teardown", + "com.groupon.seleniumgridextras.tasks.MoveMouse", + "com.groupon.seleniumgridextras.tasks.RebootNode", + "com.groupon.seleniumgridextras.tasks.VideoRecorder", + "com.groupon.seleniumgridextras.tasks.KillAllIE", + "com.groupon.seleniumgridextras.tasks.KillAllFirefox", + "com.groupon.seleniumgridextras.tasks.KillAllChrome", + "com.groupon.seleniumgridextras.tasks.KillAllEdge", + "com.groupon.seleniumgridextras.tasks.KillAllSafari", + "com.groupon.seleniumgridextras.tasks.SetAutoLogonUser", + "com.groupon.seleniumgridextras.tasks.GetProcesses", + "com.groupon.seleniumgridextras.tasks.KillPid", + "com.groupon.seleniumgridextras.tasks.Netstat", + "com.groupon.seleniumgridextras.tasks.Screenshot", + "com.groupon.seleniumgridextras.tasks.ExposeDirectory", + "com.groupon.seleniumgridextras.tasks.StartGrid", + "com.groupon.seleniumgridextras.tasks.GetInfoForPort", + "com.groupon.seleniumgridextras.tasks.GridStatus", + "com.groupon.seleniumgridextras.tasks.KillAllByName", + "com.groupon.seleniumgridextras.tasks.StopGrid", + "com.groupon.seleniumgridextras.tasks.GetConfig", + "com.groupon.seleniumgridextras.tasks.StopGridExtras", + "com.groupon.seleniumgridextras.tasks.IEProtectedMode", + "com.groupon.seleniumgridextras.tasks.IEMixedContent", + "com.groupon.seleniumgridextras.tasks.Resolution", + "com.groupon.seleniumgridextras.tasks.SystemInfo", + "com.groupon.seleniumgridextras.tasks.GetNodeConfig", + "com.groupon.seleniumgridextras.tasks.UpdateNodeConfig", + "com.groupon.seleniumgridextras.tasks.AutoUpgradeDrivers", + "com.groupon.seleniumgridextras.tasks.DownloadWebdriver", + "com.groupon.seleniumgridextras.tasks.DownloadIEDriver", + "com.groupon.seleniumgridextras.tasks.DownloadChromeDriver", + "com.groupon.seleniumgridextras.tasks.DownloadGeckoDriver", + "com.groupon.seleniumgridextras.tasks.DownloadEdgeDriver", + "com.groupon.seleniumgridextras.tasks.SessionHistory", + "com.groupon.seleniumgridextras.tasks.UpgradeGridExtrasTask" + ], + "hub_config_files": [], + "config_puller_http_timeout": 5000.0, + "auto_start_hub": "0", + "unregisterNodeDuringReboot": "true", + "chromedriver": { + "bit": "32", + "directory": "/tmp/update_driver_test", + "version": "2.22" + }, + "disabled_modules": [ + "com.groupon.seleniumgridextras.tasks.GetFile" + ], + "grid_extras_auto_update_check_interval": "86400000", + "auto_start_node": "1", + "hub_config": { + "role": "hub", + "port": "4444", + "servlets": "com.groupon.seleniumgridextras.grid.servlets.ProxyStatusJsonServlet", + "host": "192.168.0.102" + }, + "log_maximum_age_ms": 8.64E8, + "grid_extras_port": 3000.0, + "grid": {}, + "setup": [ + "com.groupon.seleniumgridextras.tasks.MoveMouse" + ], + "grid_jvm_options": {}, + "node_config_files": [], + "grid_extras_jvm_options": {}, + "enable_session_history": "1" + } +} \ No newline at end of file diff --git a/latest.go b/latest.go index a46e76dc..9536d3d7 100644 --- a/latest.go +++ b/latest.go @@ -72,7 +72,7 @@ type Uploader struct { } func get_latest_release() { - resp, err := http.Get("https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases") + resp, err := http.Get("https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases") if err != nil { log.Fatal(err) } diff --git a/latest.rb b/latest.rb index bac0c953..7bd92f00 100644 --- a/latest.rb +++ b/latest.rb @@ -3,7 +3,7 @@ require 'fileutils' # assuming latest is first tag entry -latest_json = JSON.parse(`curl -s https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases`)[0] +latest_json = JSON.parse(`curl -s https://api.github.com/repos/chamiz/Selenium-Grid-Extras/releases`)[0] latest_json["assets"].each do |asset| if asset["content_type"] == "application/java-archive"