FlagsDefinition MapDefinition(SerializableFlagsDefinition definition) { if (definition == null) { return(null); } if (definition.BrowserName == null || !definition.BrowserName.Any()) { return(null); } if ((definition.Flags == null || !definition.Flags.Any()) && (definition.RemoveFlags == null || !definition.RemoveFlags.Any())) { return(null); } var output = new FlagsDefinition { BrowserNames = new HashSet <string>(definition.BrowserName ?? Enumerable.Empty <string>()), AddFlags = new HashSet <string>(definition.Flags ?? Enumerable.Empty <string>()), RemoveFlags = new HashSet <string>(definition.RemoveFlags ?? Enumerable.Empty <string>()), }; if (definition.Platform != null) { output.Platforms = new HashSet <string>(definition.Platform ?? Enumerable.Empty <string>()); } if (definition.MinVersion != null) { output.MinimumVersion = versionFactory.CreateVersion(definition.MinVersion, definition.BrowserName.First()); } if (definition.MaxVersion != null) { output.MaximumVersion = versionFactory.CreateVersion(definition.MaxVersion, definition.BrowserName.First()); } return(output); }
/// <summary> /// Gets a browser identification instance from the given web driver. /// </summary> /// <returns>The identification.</returns> /// <param name="webDriver">A web drivr which has capabilities.</param> /// <param name="desiredCapabilities">The originally-requested capabilities.</param> public BrowserIdentification GetIdentification(IHasCapabilities webDriver, ICapabilities desiredCapabilities) { if (webDriver == null) { return(BrowserIdentification.UnidentifiedBrowser); } var platform = webDriver.Capabilities.Platform.ToString(); var browserName = webDriver.Capabilities.BrowserName; var actualVersion = webDriver.Capabilities.Version; var requestedVersion = GetRequestedVersion(webDriver, desiredCapabilities); var version = versionFactory.CreateVersion(actualVersion, browserName, requestedVersion); return(new BrowserIdentification(browserName, version, platform)); }