private UserBrowser GetBrowser(TargetOS targetOS, TargetBrowser targetBrowser) { return(new UserBrowser() .SetBaseUrl(_config.Url) .SetTargetDevice(TargetDevice.Mobile) .SetTargetBrowser(targetBrowser) .SetDriver(new DriverSetup(GetSauceLabsSettings(), GetDriverOptions(targetOS, targetBrowser), GetSauceLabsOptions()))); }
private UserBrowser GetBrowser(TargetOS targetOS, TargetBrowser targetBrowser, string browserVersion = "latest") { return(new UserBrowser() .SetBaseUrl(_config.Url) .SetTargetDevice(TargetDevice.Desktop) .SetTargetBrowser(targetBrowser) .SetDriver(new DriverSetup(GetSauceLabsSettings(), GetDriverOptions(targetOS, targetBrowser, browserVersion), GetSauceLabsOptions()))); }
private static bool EnableLogging(TargetOS os, TargetBrowser browser, ScenarioInfo scenario) { if (os == TargetOS.Windows && browser == TargetBrowser.Firefox) { return(false); } return(!scenario.Tags.Contains("DisableLogging")); }
private static DriverOptions GetDriverOptions(TargetOS targetOS, TargetBrowser targetBrowser) { return(new DriverOptions { TargetDevice = TargetDevice.Mobile, TargetOS = targetOS, TargetBrowser = targetBrowser, TargetDeviceOrientation = TargetDeviceOrientation.PORTRAIT }); }
private static DriverOptions GetDriverOptions(TargetOS targetOS, TargetBrowser targetBrowser, string browserVersion) { return(new DriverOptions { TargetDevice = TargetDevice.Desktop, TargetOS = targetOS, TargetBrowser = targetBrowser, TargetBrowserVersion = browserVersion }); }
private static DriverOptions GetDriverOptions(TargetOS targetOS, TargetBrowser targetBrowser) { return(new DriverOptions { TargetBrowserVersion = "latest", TargetDevice = TargetDevice.Desktop, TargetOS = targetOS, TargetBrowser = targetBrowser }); }
public static CalculatorAppPageObject Launch(string url, TargetBrowser targetBrowser = TargetBrowser.InternetExplorer, int width = 1024, int height = 768) { var browser = LaunchWebDriver(url, targetBrowser, width, height); var app = new CalculatorAppPageObject(browser) { BaseUri = new Uri(url), Browser = browser }; return(app); }
protected static IWebDriver LaunchWebDriver(string url, TargetBrowser targetBrowser = TargetBrowser.InternetExplorer, int width = 1024, int height = 768, bool useAngular = false) { IWebDriver browser = null; switch (targetBrowser) { case TargetBrowser.InternetExplorer: var ieOptions = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true }; browser = useAngular ? (IWebDriver) new NgWebDriver(new InternetExplorerDriver(ieOptions)) : new InternetExplorerDriver(ieOptions); break; case TargetBrowser.Edge: var edgeOptions = new EdgeOptions { PageLoadStrategy = EdgePageLoadStrategy.Eager }; browser = useAngular ? (IWebDriver) new NgWebDriver(new EdgeDriver(edgeOptions)) : new EdgeDriver(edgeOptions); break; case TargetBrowser.Chrome: browser = useAngular ? (IWebDriver) new NgWebDriver(new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))) : new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)); break; case TargetBrowser.Firefox: browser = useAngular ? (IWebDriver) new NgWebDriver(new FirefoxDriver()) : new FirefoxDriver(); break; case TargetBrowser.Safari: browser = useAngular ? (IWebDriver) new NgWebDriver(new SafariDriver()) : new SafariDriver(); break; case TargetBrowser.PhantomJSDriver: browser = useAngular ? (IWebDriver) new NgWebDriver(new PhantomJSDriver()) : new PhantomJSDriver(); break; default: throw new ArgumentException($"Unknown target browser type {targetBrowser}"); } browser.Manage().Window.Size = new Size(width, height); browser.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); browser.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30); browser.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(30); browser.Navigate().GoToUrl(url); return(browser); }
protected static IWebDriver LaunchWebDriver(string url, TargetBrowser targetBrowser = TargetBrowser.InternetExplorer, int width = 1024, int height = 768) { IWebDriver browser = null; switch (targetBrowser) { case TargetBrowser.InternetExplorer: var ieOptions = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true }; browser = new NgWebDriver(new InternetExplorerDriver(ieOptions)); break; case TargetBrowser.Edge: var edgeOptions = new EdgeOptions { PageLoadStrategy = EdgePageLoadStrategy.Eager }; browser = new NgWebDriver(new EdgeDriver(edgeOptions)); break; case TargetBrowser.Chrome: browser = new NgWebDriver(new ChromeDriver()); break; case TargetBrowser.Firefox: browser = new NgWebDriver(new FirefoxDriver()); break; case TargetBrowser.Safari: browser = new NgWebDriver(new SafariDriver()); break; default: throw new ArgumentException($"Unknown target browser type {targetBrowser}"); } browser.Manage().Window.Size = new Size(width, height); browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); browser.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(10)); browser.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(10)); // Set script timeouts to 5 secs browser.Navigate().GoToUrl(url); return(browser); }
private static void CheckIfBrowserIgnored(string tag, TargetBrowser browser, string title) { if (tag.Equals("NotChrome") && browser == TargetBrowser.Chrome || tag.Equals("NotEdge") && browser == TargetBrowser.Edge || tag.Equals("NotEdgeChromium") && browser == TargetBrowser.EdgeChromium || tag.Equals("NotFirefox") && browser == TargetBrowser.Firefox || tag.Equals("NotIE") && browser == TargetBrowser.Ie11 || tag.Equals("NotSafari") && browser == TargetBrowser.Safari || tag.Equals("ChromeOnly") && browser != TargetBrowser.Chrome || tag.Equals("EdgeOnly") && browser != TargetBrowser.Edge || tag.Equals("EdgeChromiumOnly") && browser != TargetBrowser.EdgeChromium || tag.Equals("FirefoxOnly") && browser != TargetBrowser.Firefox || tag.Equals("IEOnly") && browser != TargetBrowser.Ie11 || tag.Equals("SafariOnly") && browser != TargetBrowser.Safari) { Assert.Ignore($"Ignoring the '{title}' test on {browser}, as this functionality is not supported for this browser."); } }
public DevFunAppPageObject Launch(string url = null, TargetBrowser targetBrowser = TargetBrowser.Undefined, int width = 0, int height = 0) { if (url == null) { url = TestContext?.Properties["baseUrl"]?.ToString(); if (url == null) { throw new ArgumentNullException("Invalid base url parameter detected in the test context"); } } if (targetBrowser == TargetBrowser.Undefined) { if (!Enum.TryParse(TestContext?.Properties["targetBrowser"]?.ToString(), true, out targetBrowser)) { throw new ArgumentNullException("Invalid target browser parameter detected in the test context"); } } if (width <= 0 || height <= 0) { if (!int.TryParse(TestContext?.Properties["resolutionWidth"].ToString(), out width)) { throw new ArgumentNullException("Invalid resolution width parameter detected in the test context"); } if (!int.TryParse(TestContext?.Properties["resolutionHeight"].ToString(), out height)) { throw new ArgumentNullException("Invalid resolution height parameter detected in the test context"); } } if (CurrentApplication != null) { CloseCurrentApplication(); } this.BaseUrl = url; this.CurrentApplication = DevFunAppPageObject.Launch(url, targetBrowser, width, height); return(CurrentApplication); }
public SeleniumEnvironment(SauceLabsSettings saucelabsSettings, ScenarioInfo scenario, TargetBrowser targetBrowser) { _saucelabsSettings = saucelabsSettings; _scenario = scenario; _targetBrowser = targetBrowser; }
private static Dictionary <ReleaseChannel, VersionModel> FetchAndAssignVersionFromApi(TargetBrowser targetBrowser, Platform platform, List <ReleaseChannel> channels, IEnumerable <ApiVersion> apiVersions) { var versionsPerChannel = new Dictionary <ReleaseChannel, VersionModel>(channels.Count); VersionChannels versionChannels; switch (targetBrowser) { case TargetBrowser.Firefox: switch (platform) { case Platform.Desktop: versionChannels = ConvertFirefoxDesktopNamingToUseful(apiVersions.OfType <FirefoxDesktopApiVersion>().First()); break; case Platform.Android: case Platform.Ios: versionChannels = ConvertFirefoxMobileNamingToUseful(apiVersions.OfType <FirefoxMobileApiVersion>().First(), platform); break; default: return(versionsPerChannel); } break; case TargetBrowser.Chrome: versionChannels = ConvertChromeNamingToUseful(apiVersions.OfType <ChromeApiModel>().ToList(), platform); break; case TargetBrowser.InternetExplorer: versionChannels = platform switch { Platform.Desktop => new VersionChannels { Esr = "11.0.220", Stable = "11.0.220", }, _ => new VersionChannels() }; break; case TargetBrowser.Edge: versionChannels = ConvertEdgeNamingToUseful(apiVersions.OfType <EdgeApiVersion>().First()); break; default: return(versionsPerChannel); } foreach (var channel in channels) { versionsPerChannel[channel] = new VersionModel { Version = channel switch { ReleaseChannel.Beta => versionChannels.Beta, ReleaseChannel.Esr => versionChannels.Esr, ReleaseChannel.Develop => versionChannels.Develop, ReleaseChannel.Nightly => versionChannels.Nightly, ReleaseChannel.Stable => versionChannels.Stable, _ => throw new ArgumentOutOfRangeException(nameof(channels), "Channel does not match any given type") } }; } return(versionsPerChannel); }
public ShouldTestBeIgnored WithBrowser(TargetBrowser browser) { _browser = browser; return(this); }
private RemoteWebDriver CreateLocalDriver(TargetBrowser browserType) { Log.DebugFormat("Creating a local driver of type {0}", browserType); RemoteWebDriver driver; switch (browserType) { case TargetBrowser.FireFox: driver = new FirefoxDriver(new FirefoxBinary(), new FirefoxProfile(), _settings.Timeout); break; case TargetBrowser.InternetExplorer: driver = new InternetExplorerDriver(_settings.SeleniumServerPort, GetIEOptions(), _settings.Timeout); break; case TargetBrowser.GoogleChrome: driver = new ChromeDriver(_settings.ChromeDriverDirectory, GetChromeOptions(), _settings.Timeout); break; default: throw new NotSupportedException("Cannot create a browser of type " + browserType); } return driver; }
public UserBrowser SetTargetBrowser(TargetBrowser targetBrowser) { _targetBrowser = targetBrowser; return(this); }