diff --git a/README.md b/README.md index 80227b62..bf9f0cb6 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ and brings most (and more) of its benefits to UI5 applications. * Use generated snippets from [Test Recorder](https://blogs.sap.com/2020/01/23/test-recording-with-ui5-test-recorder/) that is build-in every UI5 app (from UI5 1.74) * Open-source, fork and modify to fit your specific neeeds. + ## Requirements * [NodeJS](https://nodejs.org/en/download/), version 8.0 or higher diff --git a/conf/profile.conf.js b/conf/profile.conf.js index af9ce8c5..7e3dd26f 100644 --- a/conf/profile.conf.js +++ b/conf/profile.conf.js @@ -49,6 +49,20 @@ exports.config = { 'IEDriverServer_Win32_${connectionConfigs.direct.binaries.iedriver.version}.' + '${connectionConfigs.direct.binaries.iedriver.patch}.zip', executable: 'IEDriverServer.exe' }, + // edge based on chromium; Note: If on a Windows 64bit system the variable osTypeString returns win32 string (see uiveri5.js), then maintain the url below with e.g. edgedriver_win64.zip + edgedriver: { + version: '{edge.latest}', + unzip: true, + filename: '${osTypeString == "win32" || osTypeString == "win64" ? "msedgedriver.exe" : "msedgedriver"}', + baseurl: 'https://msedgedriver.azureedge.net', + url: '${connectionConfigs.direct.binaries.edgedriver.baseurl}/${connectionConfigs.direct.binaries.edgedriver.version}'+'/edgedriver_${osTypeString}.zip', + latestCompleteVersionFileUrl: 'https://raw.githubusercontent.com/SAP/ui5-uiveri5/master/driverVersions.json', + executable: { + win32: 'msedgedriver-${connectionConfigs.direct.binaries.edgedriver.version}.exe', + win64: 'msedgedriver-${connectionConfigs.direct.binaries.edgedriver.version}.exe', + mac64: 'msedgedriver-${connectionConfigs.direct.binaries.edgedriver.version}' + } + }, geckodriver: { version: '{latest}', unzip: '${osTypeString == "win32" || osTypeString == "win64"}', @@ -83,7 +97,7 @@ exports.config = { } }, /* maximize browser on all desktops to ensure consistent browser size */ - 'firefox,ie,edge,safari,chrome,chromium': { + 'firefox,ie,edge,edgelegacy,safari,chrome,chromium': { 'windows,mac,linux': { '*': { remoteWebDriverOptions: { @@ -201,10 +215,10 @@ exports.config = { }, */ /* - 'edge': { + 'edgelegacy': { '*': { '*': { - edgedriverOptions: { + edgelegacydriverOptions: { 'setPageLoadStrategy': ['normal'], } } diff --git a/docs/config/config.md b/docs/config/config.md index 74ec1a52..139511ba 100644 --- a/docs/config/config.md +++ b/docs/config/config.md @@ -38,7 +38,7 @@ Browser runtime is an object that specifies the browser and platform on which to You can specify only a few of the properties of a runtime. The rest are derived if possible or wildcards are assumed. Values and defaults: -* browserName - one of (chrome|firefox|ie|safari|edge), browser name, default: chrome +* browserName - one of (chrome|firefox|ie|safari|edge|edgelegacy), browser name, default: chrome * browserVersion - browser version, default: * * platformName - one of (windows|mac|linux|android|ios|winphone)} - platform name, default: windows * platformVersion - platform number like 7,8 for windows; 4.4,5.0 for android;, default: * diff --git a/docs/config/drivers.md b/docs/config/drivers.md index 336eeb27..db4337a4 100644 --- a/docs/config/drivers.md +++ b/docs/config/drivers.md @@ -130,6 +130,19 @@ browsers: [{ }] ``` +## Microsoft Edge (based on Chromium) +Microsoft Edge Driver is downloadable separately from Windows. Please make sure you have the correct version installed as explained in [Microsoft Edge](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/). The WebDriver release version should match browser version, for example, for Microsoft Edge (based on Chromium) Release 79, choose WebDriver Release 79. The downloaded driver should be moved to /selenium/ without renaming. +```javascript +browsers: [{ + browserName: 'edge', + capabilities: { + remoteWebDriverOptions: { + maximized: true + } + } +}] +``` + ## Firefox Firefox uses the geckodriver that is updated regularly, so by default, we use the latest version. @@ -181,8 +194,8 @@ browsers: [{ }] ``` -## Edge -Microsoft Edge requires a WebDriver that is distributed as a native installation. Please make sure you have the correct version installed as explained in [Microsoft Edge WebDriver](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/). The release version should match the first part of your OS build, for example, for OS build number 15063.0000, choose driver Release 15063. The downloaded driver should be moved to /selenium/ without renaming. +## Edge Legacy +Microsoft Edge Legacy requires a WebDriver that is distributed as a native installation. Please make sure you have the correct version installed as explained in [Microsoft Edge Legacy](https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/). The release version should match the first part of your OS build, for example, for OS build number 15063.0000, choose driver Release 15063. The downloaded driver should be moved to /selenium/ without renaming. ## Safari Safari10 includes native webdriver that is bundled with the Safari browser. Please make sure you have enabled it as explained in [Testing with WebDriver in Safari](https://developer.apple.com/documentation/webkit/testing_with_webdriver_in_safari). diff --git a/driverVersions.json b/driverVersions.json index 1eb1135b..48a60dc4 100644 --- a/driverVersions.json +++ b/driverVersions.json @@ -1,5 +1,8 @@ { "chrome": { "latest": 84 + }, + "edge": { + "latest": "84.0.522.59" } } diff --git a/src/connection/directConnectionProvider.js b/src/connection/directConnectionProvider.js index a356374f..36d08109 100644 --- a/src/connection/directConnectionProvider.js +++ b/src/connection/directConnectionProvider.js @@ -18,7 +18,8 @@ var BINARIES = { SELENIUM: 'selenium', CHROMEDRIVER: 'chromedriver', IEDRIVER: 'iedriver', - GECKODRIVER: 'geckodriver' + GECKODRIVER: 'geckodriver', + EDGEDRIVER: 'edgedriver' }; /** @@ -85,6 +86,8 @@ DirectConnectionProvider.prototype.resolveCapabilitiesFromRuntime = function(run capabilities.browserName = 'internet explorer'; } else if (runtime.browserName === 'edge') { capabilities.browserName = 'MicrosoftEdge'; + } else if (runtime.browserName === 'edgelegacy') { + capabilities.browserName = 'MicrosoftEdgeLegacy'; } else { capabilities.browserName = runtime.browserName; } @@ -190,10 +193,16 @@ DirectConnectionProvider.prototype.setupEnv = function() { }) ); } else if (browserName == 'edge') { + promises.push(that._getBinaryFileName(BINARIES.EDGEDRIVER).then( + function(filename){ + that.seleniumConfig.executables.edgedriver = filename; + }) + ); + } else if (browserName == 'edgelegacy') { promises.push((function() { var deferred = q.defer(); var filename = path.join(that._getSeleniumRoot(), 'MicrosoftWebDriver.exe'); - that.seleniumConfig.executables.edgedriver = filename; + that.seleniumConfig.executables.edgelegacydriver = filename; deferred.resolve(filename); return deferred.promise; })()); @@ -471,6 +480,8 @@ DirectDriverProvider.prototype.getNewDriver = function() { opts.jvmArgs.push('-Dwebdriver.ie.driver=' + that.seleniumConfig.executables.iedriver); } else if (browserName == 'MicrosoftEdge') { opts.jvmArgs.push('-Dwebdriver.edge.driver=' + that.seleniumConfig.executables.edgedriver); + } else if (browserName == 'MicrosoftEdgeLegacy') { + opts.jvmArgs.push('-Dwebdriver.edgelegacy.driver=' + that.seleniumConfig.executables.edgelegacydriver); } var seleniumServer = new that.deps.remote.SeleniumServer(that.seleniumConfig.executables.selenium,opts); @@ -568,6 +579,7 @@ DirectDriverProvider.prototype.getNewDriver = function() { var allIECapabilities = driverOptions.toCapabilities(browserOptions.toCapabilities()); // start the local iedriver and connect to it driver = that.deps.ie.Driver.createSession(that.deps.ie.Options.fromCapabilities(allIECapabilities)); + } else if (browserName == 'MicrosoftEdge') { that.deps.edge = protractorModule.require('selenium-webdriver/edge'); @@ -586,6 +598,24 @@ DirectDriverProvider.prototype.getNewDriver = function() { // start the local edgedriver and connect to it var edgeServiceBuilder = new that.deps.edge.ServiceBuilder(that.seleniumConfig.executables.edgedriver); driver = that.deps.edge.Driver.createSession(allEdgeCapabilities, edgeServiceBuilder.build()); + } else if (browserName == 'MicrosoftEdgeLegacy') { + that.deps.edgelegacy = protractorModule.require('selenium-webdriver/edge'); + + that.logger.debug('Starting local edgelegacydriver with executable: ' + + that.seleniumConfig.executables.edgelegacydriver); + + var edgelegacyOptions = [new that.deps.edgelegacy.Options(), new that.deps.edgelegacy.Options()]; + _.forEach(['edgelegacydriverOptions', 'edgelegacyOptions'], function (capabilitiesKey, index) { + _.forIn(that.protConfig.capabilities[capabilitiesKey], function (value, key) { + that.deps.edgelegacy.Options.prototype[key].apply(edgelegacyOptions[index], value); + }); + }); + // merge capabilities + var allEdgeLegacyCapabilities = edgelegacyOptions[0].toCapabilities(edgelegacyOptions[1].toCapabilities()); + + // start the local edgelegacy driver and connect to it + var edgeLegacyServiceBuilder = new that.deps.edgelegacy.ServiceBuilder(that.seleniumConfig.executables.edgelegacydriver); + driver = that.deps.edgelegacy.Driver.createSession(allEdgeLegacyCapabilities, edgeLegacyServiceBuilder.build()); } else if (browserName == 'safari') { that.deps.safari = protractorModule.require('selenium-webdriver/safari'); diff --git a/src/connection/latestDriverVersionResolver.js b/src/connection/latestDriverVersionResolver.js index 2225e637..4f8db504 100644 --- a/src/connection/latestDriverVersionResolver.js +++ b/src/connection/latestDriverVersionResolver.js @@ -9,16 +9,46 @@ function LatestDriverVersionResolver(config, instanceConfig, logger) { LatestDriverVersionResolver.prototype.getLatestVersion = function (binary) { var that = this; - return that._getLatestMajorVersion(binary) - .then(function (result) { - if (result.latestMajorVersion) { - binary.latestVersionUrl = binary.latestVersionUrl.replace(that.latestVersionRegexp, result.latestMajorVersion); - } - return that._getLatestDriverVersion(binary); - }); + + if (binary.latestCompleteVersionFileUrl) { + return that._getLatestCompleteVersionFromFile(binary); + } else { + return that._getLatestMajorVersionFromFile(binary) + .then(function (result) { + if (result.latestMajorVersion) { + binary.latestVersionUrl = binary.latestVersionUrl.replace(that.latestVersionRegexp, result.latestMajorVersion); + } + return that._getLatestDriverVersion(binary); + }); + } +}; + +LatestDriverVersionResolver.prototype._getLatestCompleteVersionFromFile = function (binary) { + var that = this; + + that.logger.info('Check for latest complete version of: ' + binary.filename); + return q.Promise(function (resolveFn, rejectFn) { + if (binary.latestCompleteVersionFileUrl) { + request({ + url: binary.latestCompleteVersionFileUrl + }, function (error, res, body) { + if (_hasError(error, res)) { + rejectFn(_buildErrorObject(error, res, binary.filename, 'the latest version number')); + } else { + var latestVersion = _parseVersionNumber(body, binary.version); + that.logger.info('Found latest complete version of ' + binary.filename + ': ' + latestVersion); + resolveFn({ + latestVersion: latestVersion + }); + } + }); + } else { + resolveFn({}); + } + }); }; -LatestDriverVersionResolver.prototype._getLatestMajorVersion = function (binary) { +LatestDriverVersionResolver.prototype._getLatestMajorVersionFromFile = function (binary) { var that = this; that.logger.info('Check for latest major version of: ' + binary.filename); diff --git a/src/runtimeResolver.js b/src/runtimeResolver.js index 032ac480..10eb901b 100644 --- a/src/runtimeResolver.js +++ b/src/runtimeResolver.js @@ -23,7 +23,7 @@ var platformNamePerOsTypeString = { mac64: 'mac' }; var supportedBrowserNames = [ - 'chrome','chromium','browser','chromeMobileEmulation','firefox','ie','safari','edge','chromeHeadless' + 'chrome','chromium','browser','chromeMobileEmulation','firefox','ie','safari','edge','edgelegacy','chromeHeadless' ]; var supportedPlatformNames = [ 'windows','mac','linux','android','ios','winphone' @@ -41,7 +41,7 @@ var supportedUI5Modes = [ /** * @typedef Runtime * @type {Object} - * @param {string(chrome|chromium|browser|firefox|ie|safari|edge)} browserName - browser name, default: chrome + * @param {string(chrome|chromium|browser|firefox|ie|safari|edge|edgelegacy)} browserName - browser name, default: chrome * @param {number} browserVersion - browser version, default: * * @param {string(windows|mac|linux|android|ios|winphone)} platformName - platform name, default: windows * @param {number} platformVersion - platform number like 7,8 for windows; 4.4,5.0 for android;, default: *