private DriverOptions GetNativeCapabilities() { DriverOptions driverOptions = null; switch (mContextType) { case eContextType.NativeIOS: case eContextType.NativeAndroid: driverOptions = new AppiumOptions(); break; case eContextType.WebAndroid: driverOptions = new ChromeOptions(); break; case eContextType.WebIOS: driverOptions = new SafariOptions(); break; default: break; } driverOptions.AddAdditionalCapability("user", Perfecto_User_Name); driverOptions.AddAdditionalCapability("password", Perfecto_Password); driverOptions.AddAdditionalCapability("deviceName", Perfecto_Device_ID); return(driverOptions); }
/// <summary> /// /// </summary> /// <param name=""></param> /// <returns></returns> public static void LoadSafariDriver(int CurrentAttempt) { if (CurrentAttempt <= BrowserRetryMax) { try { if (CurrentAttempt == 0) { KillSafariDriver(); } SafariDriverService serv = SafariDriverService.CreateDefaultService("/Applications/Safari Technology Preview.app/Contents/MacOS/", "safaridriver"); SafariOptions opts = new SafariOptions(); opts.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true); opts.AddAdditionalCapability(CapabilityType.AcceptInsecureCertificates, true); opts.AddAdditionalCapability("cleanSession", true); webDriver = new SafariDriver(serv, opts); Test.Log.Message("Safari " + browserVersion); } catch (Exception ex) { Test.Log.Message("Error Safari driver failed to load: " + ex.Message); LoadSafariDriver(CurrentAttempt++); } } }
private static DriverOptions GetiOSSafariOptions() { SafariOptions options = new SafariOptions(); options.AddAdditionalCapability("deviceName", "iPhone X Simulator"); options.AddAdditionalCapability("platformVersion", "11.2"); options.PlatformName = "iOS"; return(options); }
private void setDriverOptions(ref SafariOptions driverOptions, string PlatformName, string BrowserVersion) { var sauceOptions = new Dictionary <string, object>(); sauceOptions.Add("username", SAUCE_USERNAME); sauceOptions.Add("accesskey", SAUCE_ACCESS_KEY); driverOptions.PlatformName = PlatformName; driverOptions.BrowserVersion = BrowserVersion; driverOptions.AddAdditionalCapability("username", SAUCE_USERNAME); driverOptions.AddAdditionalCapability("accesskey", SAUCE_ACCESS_KEY); }
/// <summary> /// Get the remote desired capability /// </summary> /// <returns>The remote desired capability</returns> private static ICapabilities GetRemoteCapabilities() { DriverOptions options = null; string remoteBrowser = GetRemoteBrowserName(); string remotePlatform = GetRemotePlatform(); string remoteBrowserVersion = GetRemoteBrowserVersion(); switch (remoteBrowser.ToUpper()) { case "INTERNET EXPLORER": case "INTERNETEXPLORER": case "IE": options = new InternetExplorerOptions(); break; case "FIREFOX": options = new FirefoxOptions(); break; case "CHROME": options = new ChromeOptions(); break; case "EDGE": options = new EdgeOptions(); break; case "SAFARI": options = new SafariOptions(); break; default: throw new ArgumentException(StringProcessor.SafeFormatter("Remote browser type '{0}' is not supported", remoteBrowser)); } // Add a platform setting if one was provided if (remotePlatform.Length > 0) { options.AddAdditionalCapability("platform", remotePlatform); } // Add a remote browser setting if one was provided if (remoteBrowserVersion.Length > 0) { options.AddAdditionalCapability("version", remoteBrowserVersion); } // Add RemoteCapabilites section if it exists options.SetDriverOptions(); return(options.ToCapabilities()); }
protected SafariOptions getSafariOptions() { var safariOptions = new SafariOptions(); //if (!String.IsNullOrEmpty(directory)) // safariOptions.SafariLocation = directory; if (_profile != null) { throw new Exception("Profile configuration is not available for Safari driver!"); } if (_preferences != null) { throw new Exception("Preference configuration is not available for Safari!"); } if (_extensions != null && _extensions.Count != 0) { safariOptions.CustomExtensionPath = _extensions[0]; } if (_proxy != null) { throw new Exception("Proxy configuration is not available for Safari!"); } foreach (var capability in _capabilities) { safariOptions.AddAdditionalCapability(capability.Key, capability.Value); } return(safariOptions); }
public void SafariDriverTest() { var options = new SafariOptions(); options.AddAdditionalCapability(CapabilityType.Version, "latest"); options.AddAdditionalCapability(CapabilityType.Platform, "macOS 10.13"); options.AddAdditionalCapability("username", sauceUserName); options.AddAdditionalCapability("accessKey", sauceAccessKey); using (var driver = new RemoteWebDriver(RemoteAddress, options.ToCapabilities(), CommandTimeout)) { //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30); //driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10); driver.Navigate().GoToUrl("https://login.live.com"); } }
private static SafariOptions GetSafariOptions() { var options = new SafariOptions(); options.AddAdditionalCapability("cleanSession", true); return(options); }
private static RemoteWebDriver StartSafariDriver(DriverSettings settings) { var options = new SafariOptions(); settings.Capabilities?.ForEach(cap => options.AddAdditionalCapability(cap.Key, cap.Value)); return(new SafariDriver(options)); }
private static SafariOptions SafariOptions() { var options = new SafariOptions(); options.AddAdditionalCapability("safari.options", "skipExtensionInstallation"); return(options); }
private SafariOptions GetSafariDriverOptions() { SafariOptions options = new SafariOptions(); foreach (KeyValuePair <string, object> keyValuePair in _config.AdditionalCapability) { options.AddAdditionalCapability(keyValuePair.Key, keyValuePair.Value); } return(options); }
public static IWebDriver CreateSauceDriver(SauceConfigurations sauceConfigurations) { var sauceOptions = new Dictionary <string, object> { { "screenResolution", sauceConfigurations.ScreenResolution }, { "username", SauceUserName }, { "accessKey", SauceAccessKey }, { "deviceName", sauceConfigurations.DeviceName }, { "deviceOrientation", sauceConfigurations.DeviceOrientation }, { "name", TestContext.CurrentContext.Test.Name } }; switch (sauceConfigurations.Browser) { case Browser.Chrome: var chromeOptions = new ChromeOptions { UseSpecCompliantProtocol = true, PlatformName = sauceConfigurations.Os, BrowserVersion = sauceConfigurations.Version }; chromeOptions.AddAdditionalCapability("sauce:options", sauceOptions, true); return(new RemoteWebDriver(new Uri(SauceRemoteAddress), chromeOptions)); case Browser.Firefox: var firefoxOptions = new FirefoxOptions { PlatformName = sauceConfigurations.Os, BrowserVersion = sauceConfigurations.Version }; firefoxOptions.AddAdditionalCapability("sauce:options", sauceOptions, true); return(new RemoteWebDriver(new Uri(SauceRemoteAddress), firefoxOptions)); case Browser.Safari: var safariOptions = new SafariOptions { PlatformName = sauceConfigurations.Os, BrowserVersion = sauceConfigurations.Version }; safariOptions.AddAdditionalCapability("sauce:options", sauceOptions); return(new RemoteWebDriver(new Uri(SauceRemoteAddress), safariOptions)); case Browser.Edge: var edgeOptions = new EdgeOptions { PlatformName = sauceConfigurations.Os, BrowserVersion = sauceConfigurations.Version }; edgeOptions.AddAdditionalCapability("sauce:options", sauceOptions); return(new RemoteWebDriver(new Uri(SauceRemoteAddress), edgeOptions)); default: throw new ArgumentException("Invalid browser"); } }
public void ShouldOpenOnSafari() { // Set your sauce user name and access key from environment variables var sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User); var sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User); //configure sauce labs options var sauceOptions = new Dictionary <string, object> { ["username"] = sauceUserName, ["accessKey"] = sauceAccessKey, ["name"] = MethodBase.GetCurrentMethod().Name }; //configure the browser options var safariOptions = new SafariOptions { BrowserVersion = "latest", PlatformName = "macOS 10.15", //AcceptInsecureCertificates = true Don't use this as Safari doesn't support Insecure certs }; //merge sauce options with browser options safariOptions.AddAdditionalCapability("sauce:options", sauceOptions); //It's not a good idea to set this value too high because if something goes wrong, // the test will just hang for this amount of time. 60 sec is plenty var connectionTimeout = TimeSpan.FromSeconds(60); _driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com/wd/hub"), safariOptions.ToCapabilities(), connectionTimeout); //navigate to the url of the Sauce Labs Sample app _driver.Navigate().GoToUrl("https://www.saucedemo.com"); //Create an instance of a Selenium explicit wait so that we can dynamically wait for an element var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5)); //wait for the user name field to be visible and store that element into a variable var userNameField = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("[type='text']"))); //type the user name string into the user name field userNameField.SendKeys("standard_user"); //type the password into the password field _driver.FindElement(By.CssSelector("[type='password']")).SendKeys("secret_sauce"); //hit Login button _driver.FindElement(By.CssSelector("[type='submit']")).Click(); //Synchronize on the next page and make sure it loads var inventoryPageLocator = wait.Until(ExpectedConditions.ElementIsVisible(By.Id("inventory_container"))); //Assert that the inventory page displayed appropriately Assert.IsTrue(inventoryPageLocator.Displayed); }
private DriverOptions GetDriverOptions() { switch (this.BrowserStackSettings.BrowserName.ToLower(CultureInfo.CurrentCulture)) { case "chrome": var chromeDriverOptions = new ChromeOptions(); foreach (var capability in this.AdditionalCapabilities) { chromeDriverOptions.AddAdditionalCapability(capability.Key, capability.Value, true); } return(chromeDriverOptions); case "ie": var ieDriverOptions = new InternetExplorerOptions(); foreach (var capability in this.AdditionalCapabilities) { ieDriverOptions.AddAdditionalCapability(capability.Key, capability.Value, true); } return(ieDriverOptions); case "edge": var edgeDriverOptions = new EdgeOptions(); foreach (var capability in this.AdditionalCapabilities) { edgeDriverOptions.AddAdditionalCapability(capability.Key, capability.Value); } return(edgeDriverOptions); case "firefox": var firefoxDriverOptions = new FirefoxOptions(); foreach (var capability in this.AdditionalCapabilities) { firefoxDriverOptions.AddAdditionalCapability(capability.Key, capability.Value, true); } return(firefoxDriverOptions); case "safari": var safariDriverOptions = new SafariOptions(); foreach (var capability in this.AdditionalCapabilities) { safariDriverOptions.AddAdditionalCapability(capability.Key, capability.Value); } return(safariDriverOptions); default: throw new ArgumentOutOfRangeException("Unable to create the browser specific driver options. An update is required."); } }
private SafariOptions ConfigureLocalRealDevice() { var options = new SafariOptions(); options.AddAdditionalCapability(MobileCapabilityType.Orientation, "LANDSCAPE"); options.AddAdditionalCapability(MobileCapabilityType.PlatformName, "iOS"); options.AddAdditionalCapability(MobileCapabilityType.BrowserName, "Safari"); options.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, PlatformVersion); options.AddAdditionalCapability("safari:deviceType", "iPad"); options.AddAdditionalCapability(MobileCapabilityType.DeviceName, DeviceName); options.AddAdditionalCapability(MobileCapabilityType.Udid, UUID); options.AddAdditionalCapability(MobileCapabilityType.FullReset, false); return(options); }
public static IWebDriver OpenSafariBrowserWithUrl(IWebDriver driver, string strUrlToOpen, Boolean OpenInNewWindow = false) { try { Uri remote_grid = new Uri("http://" + "localhost" + ":" + "4444" + "/wd/hub"); DesiredCapabilities capability = null; string browser = "safari"; //if (browser == null || browser.Contains("safari")) { //SafariProfile profile = new SafariProfile(); capability = DesiredCapabilities.Safari(); capability.IsJavaScriptEnabled = true; //profile.EnableNativeEvents = true; //capability.SetCapability(SafariDriver.ProfileCapabilityName, profile); } SafariOptions so = new SafariOptions(); so.AddAdditionalCapability(DesiredCapabilities.Safari().IsJavaScriptEnabled.ToString(), true); //DesiredCapabilities capabilities = DesiredCapabilities.Safari(); //capabilities.BrowserName.Insert(0, "safari"); //ICommandExecutor executor = new SeleneseCommandExecutor( "http:localhost:4444/" ,"http://www.google.com/" , capabilities); //IWebDriver driver1 = new RemoteWebDriver(executor, capabilities); driver = new SafariDriver(so); // ScreenShotRemoteWebDriver(remote_grid, capability); //driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20)); WebDriverBackedSelenium BackedSelenium = new WebDriverBackedSelenium(driver, remote_grid); BackedSelenium.Start(); driver.Navigate().GoToUrl(strUrlToOpen); Report.AddToHtmlReportPassed("Safari Browser Open for '" + strUrlToOpen + "' ."); new Common(driver).pause(70000); driver.Manage().Window.Maximize(); //ScreenShotRemoteWebDriver sd = new ScreenShotRemoteWebDriver(remote_grid, capability); //sd.GetScreenshot().SaveAsFile() } catch (Exception ex) { //Console.WriteLine("ex::" + ex); //Console.WriteLine("ex.Message::" + ex.Message); //Console.WriteLine("ex.InnerException::" + ex.InnerException); //Console.WriteLine("ex.StackTrace::" + ex.StackTrace); //Report.AddToHtmlReportFailed(driver, ex, "Safari Browser Open for '" + strUrlToOpen + "' ."); } return(driver); }
public void SafariW3C() { var safariOptions = new SafariOptions { BrowserVersion = "latest", PlatformName = "macOS 10.15" // Don't use AcceptInsecureCertificates, as Safari doesn't support Insecure certs //AcceptInsecureCertificates = true }; _sauceOptions.Add("name", TestContext.CurrentContext.Test.Name); safariOptions.AddAdditionalCapability("sauce:options", _sauceOptions); safariOptions.AddAdditionalCapability("sauce:visual", _visualOptions); _driver = GetDriver(safariOptions); _driver.Navigate().GoToUrl("https://www.saucedemo.com"); JsExecutor.ExecuteScript("/*@visual.init*/", "Visual C# Test"); JsExecutor.ExecuteScript("/*@visual.snapshot*/", "Login Page"); }
public IWebDriver StartSafariBrowser() { var options = new SafariOptions(); // Add the WebDriver proxy capability. if (Config.Settings.httpProxy.startProxy) { var proxy = new OpenQA.Selenium.Proxy(); proxy.HttpProxy = "localhost:" + TestBase.proxy.proxyPort; options.AddAdditionalCapability("proxy", proxy); } return(new SafariDriver(options)); }
public void SafariW3C() { SafariOptions safariOptions = new SafariOptions { BrowserVersion = "12.0", PlatformName = "macOS 10.13" //AcceptInsecureCertificates = true Don't use this as Safari doesn't support Insecure certs }; sauceOptions.Add("name", MethodBase.GetCurrentMethod().Name); safariOptions.AddAdditionalCapability("sauce:options", sauceOptions); _driver = new RemoteWebDriver(SeleniumHub, safariOptions.ToCapabilities(), TimeSpan.FromSeconds(600)); GoToThenAssert(); }
public override RemoteWebDriver InitialiseForSauceLabs() { var options = new SafariOptions() { PlatformName = MacPlatform, BrowserVersion = BrowserVersion }; if (LoggingEnabled) { SauceOptions.Add("extendedDebugging", true); } options.AddAdditionalCapability("sauce:options", SauceOptions); return(new RemoteWebDriver(Uri, options)); }
public SafariBrowserOptions(SaucePlatform platform, string testName) : base(testName) { Console.WriteLine(SauceOpsConstants.SETTING_UP, testName, SauceOpsConstants.DESKTOP_ON_WEBDRIVER); DebugMessages.PrintDesktopOptionValues(platform); Console.WriteLine("Creating Safari Options"); var o = new SafariOptions { PlatformName = platform.Os, BrowserVersion = platform.BrowserVersion }; o.AddAdditionalCapability(SauceOpsConstants.SAUCE_OPTIONS_CAPABILITY, SauceOptions); Opts = o; }
public DriverOptions Options(Platforms platform, Browsers browser, String version, Dictionary <string, object> SauceOptions) { DriverOptions options = DriverOptions; switch (browser) { case Browsers.Chrome: ChromeOptions co = new ChromeOptions() { UseSpecCompliantProtocol = true }; co.AddAdditionalCapability("sauce:options", SauceOptions, true); options = co; break; case Browsers.Edge: EdgeOptions eo = new EdgeOptions(); eo.AddAdditionalCapability("sauce:options", SauceOptions); options = eo; break; case Browsers.Safari: SafariOptions so = new SafariOptions(); so.AddAdditionalCapability("sauce:options", SauceOptions); options = so; break; case Browsers.Firefox: FirefoxOptions fo = new FirefoxOptions(); fo.AddAdditionalCapability("sauce:options", SauceOptions, true); options = fo; break; } if (version.Equals("0") || version.Equals("latest")) { options.BrowserVersion = "latest"; } else { options.BrowserVersion = version; } options.PlatformName = PlatformToString(platform); return(options); }
/// <summary> /// Sets up default browser capabilities /// </summary> /// <returns></returns> private DriverOptions SetDefaultCapabilities() { DriverOptions cap = null; switch (this.browserName.ToUpper()) { case "IE": internetExplorerOptions = new InternetExplorerOptions(); internetExplorerOptions.EnableNativeEvents = true; internetExplorerOptions.EnableNativeEvents = false; internetExplorerOptions.SetLoggingPreference(LogType.Browser, LogLevel.All); cap = internetExplorerOptions; break; case "EDGE": edgeOptions = new EdgeOptions(); edgeOptions.PlatformName = "WIN10"; edgeOptions.AddAdditionalCapability(nameof(edgeOptions.BrowserName), edgeOptions.BrowserName); edgeOptions.AddAdditionalCapability(nameof(edgeOptions.PlatformName), edgeOptions.PlatformName); cap = edgeOptions; break; case "SAFARI": safariOptions = new SafariOptions(); safariOptions.PlatformName = "iOS"; safariOptions.AddAdditionalCapability(nameof(safariOptions.PlatformName), safariOptions.PlatformName); cap = safariOptions; break; case "CHROME": chromeOptions = new ChromeOptions(); chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All); chromeOptions.AddUserProfilePreference("disable-popup-blocking", "true"); chromeOptions.PageLoadStrategy = PageLoadStrategy.Normal; chromeOptions.AddArguments("--disable-impl-side-painting"); chromeOptions.AddArguments("--no-sandbox"); cap = chromeOptions; break; default: throw new InvalidCapabilityException($"Browser type [{this.context.RS_BrowserName}] is not supported. Supported types [chrome, safari]"); } return(cap); }
public override DriverOptions GetDriverOptions(string platformName, string platformVersion, string deviceName, string browserName) { string _platformName = String.IsNullOrEmpty(platformName) ? PlatformName : platformName; string _browserName = String.IsNullOrEmpty(browserName) ? BrowserName : browserName; var _key = String.IsNullOrEmpty(Environment.GetEnvironmentVariable(Env.BrowserStackKey)) ? Key : Environment.GetEnvironmentVariable(Env.BrowserStackKey); var _user = String.IsNullOrEmpty(Environment.GetEnvironmentVariable(Env.BrowserStackUser)) ? User : Environment.GetEnvironmentVariable(Env.BrowserStackUser); switch (_platformName) { case MobilePlatform.Android: case MobilePlatform.IOS: throw new DriverDoesNotSupportException("BrowserStack driver only support desktop browser test"); default: switch (_browserName) { case "Chrome": var chromeOptions = new ChromeOptions(); chromeOptions.AddAdditionalCapability("browser_version", Version, true); chromeOptions.AddAdditionalCapability("os", Os, true); chromeOptions.AddAdditionalCapability("os_version", OsVersion, true); chromeOptions.AddAdditionalCapability("resolution", Resolution, true); chromeOptions.AddAdditionalCapability("browserstack.user", _user, true); chromeOptions.AddAdditionalCapability("browserstack.key", _key, true); return(chromeOptions); case "Firefox": var firefoxOptions = new FirefoxOptions(); firefoxOptions.AddAdditionalCapability("browser_version", Version, true); firefoxOptions.AddAdditionalCapability("os", Os, true); firefoxOptions.AddAdditionalCapability("os_version", OsVersion, true); firefoxOptions.AddAdditionalCapability("resolution", Resolution, true); firefoxOptions.AddAdditionalCapability("browserstack.user", _user, true); firefoxOptions.AddAdditionalCapability("browserstack.key", _key, true); return(firefoxOptions); case "Safari": var safariOptions = new SafariOptions(); safariOptions.AddAdditionalCapability("browser_version", Version); safariOptions.AddAdditionalCapability("os", Os); safariOptions.AddAdditionalCapability("os_version", OsVersion); safariOptions.AddAdditionalCapability("resolution", Resolution); safariOptions.AddAdditionalCapability("browserstack.user", _user); safariOptions.AddAdditionalCapability("browserstack.key", _key); return(safariOptions); default: throw new BrowserDoesNotSupportException("Only support Chrome, Firefox and Safari"); } } }
private static SafariOptions SetOptions(Dictionary <string, object> capabilities) { var options = new SafariOptions(); foreach (var cap in capabilities) { if (cap.Key.StartsWith("Capability", StringComparison.OrdinalIgnoreCase)) { var args = Extensions.ParseWithDelimiter(cap.Value.ToString()); options.AddAdditionalCapability(args[0], args[1]); } else if (cap.Key.Equals("AcceptInsecureCertificates", StringComparison.OrdinalIgnoreCase)) { options.AcceptInsecureCertificates = true; } } return(options); }
public void SafariW3C() { var safariOptions = new SafariOptions { BrowserVersion = "latest", PlatformName = "macOS 10.15" //AcceptInsecureCertificates = true Don't use this as Safari doesn't support Insecure certs }; _sauceOptions.Add("name", TestContext.CurrentContext.Test.Name); safariOptions.AddAdditionalCapability("sauce:options", _sauceOptions); _driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com/wd/hub"), safariOptions.ToCapabilities(), TimeSpan.FromSeconds(600)); _driver.Navigate().GoToUrl("https://www.saucedemo.com"); Assert.Pass(); }
public AppiumIOSOptions(SaucePlatform platform, string testName) : base(testName) { Console.WriteLine(SauceOpsConstants.SETTING_UP, testName, SauceOpsConstants.IOS_ON_APPIUM); AddSauceLabsOptions(Enviro.SauceNativeApp); DebugMessages.PrintiOSOptionValues(platform); Console.WriteLine("Creating iOS Options"); Opts = new SafariOptions() { BrowserVersion = platform.BrowserVersion, PlatformName = "iOS" }; SauceOptions.Add(SauceOpsConstants.SAUCE_DEVICE_NAME_CAPABILITY, platform.Device); SauceOptions.Add(SauceOpsConstants.SAUCE_PLATFORM_VERSION_CAPABILITY, platform.SanitisedLongVersion()); SauceOptions.Add(SauceOpsConstants.SAUCE_DEVICE_ORIENTATION_CAPABILITY, platform.DeviceOrientation); Opts.AddAdditionalCapability(SauceOpsConstants.SAUCE_OPTIONS_CAPABILITY, SauceOptions); }
static void Main(string[] args) { //ChromeOptions options = new ChromeOptions(); ////options.AddAdditionalCapability("user", "neerajn", true); ////options.AddAdditionalCapability("accessKey", "RVxtO0XHRNG5VqR9pQumcJ5M9CIx6xu6QLFsGqHbrqkoz9N1GG", true); //options.AddAdditionalCapability("build", "your build name", true); //options.AddAdditionalCapability("name", "your test name", true); //options.AddAdditionalCapability("platform", "Windows 10", true); //options.AddAdditionalCapability("browser", "Chrome", true); //options.AddAdditionalCapability("version", "91.0", true); ////options.AddAdditionalCapability("deviceName", null, true); //options.AddAdditionalCapability("appiumVersion", null, true); SafariOptions options = new SafariOptions(); //options.AddAdditionalCapability("user", "neerajn"); //options.AddAdditionalCapability("accesskey", "rvxto0xhrng5vqr9pqumcj5m9cix6xu6qlfsgqhbrqkoz9n1gg"); options.AddAdditionalCapability("build", ">net safari"); options.AddAdditionalCapability("name", ""); options.AddAdditionalCapability("platformname", "macos big sur"); options.AddAdditionalCapability("browsername", "Chrome"); options.AddAdditionalCapability("browserversion", "71.0"); options.AddAdditionalCapability("deviceName", "Galaxy S20"); //options.AddAdditionalCapability("appiumVersion", null); //options.AddAdditionalCapability("selenium_version", "3.141.59", true); //options.AddAdditionalCapability("ie.driver", "3.0.0", true); //IWebDriver driver = new RemoteWebDriver(new Uri("http://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub/"), options);//prod IWebDriver driver = new RemoteWebDriver(new Uri("https://*****:*****@stage-hub.lambdatest.com/wd/hub"), options);//stage //IWebDriver driver = new RemoteWebDriver(new Uri("http://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub/"), options.ToCapabilities.TimeSpan.FromMinutes(2)); driver.Navigate().GoToUrl("https://www.google.com"); IWebElement el = driver.FindElement(By.Name("q")); el.SendKeys("LambdaTest"); IWebElement ele1 = driver.FindElement(By.Name("btnK")); ele1.Click(); driver.Quit(); }
public void Setup() { _sauceUserName = Environment.GetEnvironmentVariable("SAUCE_USERNAME", EnvironmentVariableTarget.User); _sauceAccessKey = Environment.GetEnvironmentVariable("SAUCE_ACCESS_KEY", EnvironmentVariableTarget.User); _sauceOptions = new Dictionary <string, object> { ["username"] = _sauceUserName, ["accessKey"] = _sauceAccessKey, ["deviceName"] = "iPhone XS Max Simulator", ["platformVersion"] = "13.0" }; var options = new SafariOptions { BrowserVersion = "latest", PlatformName = "iOS" }; _sauceOptions.Add("name", MethodBase.GetCurrentMethod().Name); options.AddAdditionalCapability("sauce:options", _sauceOptions); _driver = new RemoteWebDriver(new Uri("https://ondemand.saucelabs.com/wd/hub"), options.ToCapabilities(), TimeSpan.FromSeconds(30)); }
public void Init() { String Format = "{dd/M/yyyy}"; string date = DateTime.Now.ToString(Format); string browsername = string.Empty; try { // Assert.Ignore(""); NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; NameValueCollection settings = ConfigurationManager.GetSection("environments/" + environment) as NameValueCollection; // DesiredCapabilities capability = new DesiredCapabilities(); foreach (string key in caps.AllKeys) { //capability.SetCapability(key, caps[key]); } foreach (string key in settings.AllKeys) { if (key == "browser") { browsername = settings[key]; } //capability.SetCapability(key, settings[key]); } String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); if (username == null) { username = ConfigurationManager.AppSettings.Get("user"); } String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); if (accesskey == null) { accesskey = ConfigurationManager.AppSettings.Get("key"); } switch (browsername) { case "edge": EdgeOptions capability = new EdgeOptions(); capability.AddAdditionalCapability("os", "Windows"); capability.AddAdditionalCapability("os_version", "10"); capability.AddAdditionalCapability("browser", "Edge"); capability.AddAdditionalCapability("browser_version", "80.0"); capability.AddAdditionalCapability("project", "Smoke Script"); capability.AddAdditionalCapability("build", "Build 20.2_" + date); capability.AddAdditionalCapability("name", "Bstack-" + TestContext.CurrentContext.Test.Name); capability.AddAdditionalCapability("browserstack.local", "true"); capability.AddAdditionalCapability("browserstack.networkLogs", "true"); capability.AddAdditionalCapability("browserstack.video", "false"); capability.AddAdditionalCapability("browserstack.selenium_version", "3.5.2"); capability.AddAdditionalCapability("browserstack.user", username); capability.AddAdditionalCapability("browserstack.key", accesskey); browserStackLocal = new Local(); // List<KeyValuePair<string, string>> bsLocalArgs = new List<KeyValuePair<string, string>>() { // new KeyValuePair<string, string>("key", accesskey) //}; // browserStackLocal.start(bsLocalArgs); //capability = (DesiredCapabilities)chromeOptions.ToCapabilities(); driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(180); InitializeBase(driver); break; case "chrome": ChromeOptions capability1 = new ChromeOptions(); // capability.SetLoggingPreference(LogType.Browser, LogLevel.Warning); //capability.AddArguments("disable-infobars"); capability1.AddUserProfilePreference("download.prompt_for_download", false); capability1.AddUserProfilePreference("disable-popup-blocking", "true"); capability1.AddAdditionalCapability("os", "Windows", true); capability1.AddAdditionalCapability("os_version", "10", true); capability1.AddAdditionalCapability("browser", "Chrome", true); capability1.AddAdditionalCapability("browser_version", "73.0", true); capability1.AddAdditionalCapability("browserstack.local", "true", true); capability1.AddAdditionalCapability("browserstack.selenium_version", "3.14.0", true); capability1.AddAdditionalCapability("browserstack.user", "saifafzal2", true); capability1.AddAdditionalCapability("browserstack.key", "s3rbeAXDiXhSnHDXAkfs", true); capability1.AddAdditionalCapability("project", "Smoke Script", true); capability1.AddAdditionalCapability("build", "Build 20.2_" + date, true); //capability1.AddAdditionalCapability(CapabilityType.AcceptSslCertificates, true); capability1.AddAdditionalCapability("name", "Bstack-" + TestContext.CurrentContext.Test.Name, true); driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability1); driver.Manage().Window.Maximize(); driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(180); InitializeBase(driver); break; case "safari": SafariOptions capability2 = new SafariOptions(); capability2.AddAdditionalCapability("os", "OS X"); capability2.AddAdditionalCapability("os_version", "Catalina"); capability2.AddAdditionalCapability("browser", "Safari"); capability2.AddAdditionalCapability("browser_version", "13.0"); capability2.AddAdditionalCapability("browserstack.local", "true"); capability2.AddAdditionalCapability("browserstack.selenium_version", "3.14.0"); capability2.AddAdditionalCapability("browserstack.safari.enablePopups", "true"); capability2.AddAdditionalCapability("browserstack.safari.allowAllCookies", "true"); capability2.AddAdditionalCapability("browserstack.user", "saifafzal2"); capability2.AddAdditionalCapability("browserstack.key", "s3rbeAXDiXhSnHDXAkfs"); capability2.AddAdditionalCapability("project", "Smoke Script"); capability2.AddAdditionalCapability("browserstack.idleTimeout", 180); capability2.AddAdditionalCapability("build", "Build 20.2_" + date); capability2.AddAdditionalCapability("name", "Bstack-" + TestContext.CurrentContext.Test.Name); driver = new RemoteWebDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability2); driver.Manage().Window.Maximize(); // driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(180); InitializeBase(driver); break; } } catch (NullReferenceException e) { var = false; Assert.Ignore(); } }