public MobileDriver(IAutomationConfiguration configuration, BrowserDriverEnumeration browserVendor = BrowserDriverEnumeration.Android) : base(configuration, browserVendor) { BrowserVendor = browserVendor; var ops = new AppiumOptions(); ops.AddAdditionalCapability(MobileCapabilityType.DeviceName, Config.GetConfigSetting("AppiumDeviceName", "")); ops.AddAdditionalCapability(MobileCapabilityType.PlatformName, Config.GetConfigSetting("AppiumPlatformName", "")); ops.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, Config.GetConfigSetting("AppiumPlatformVersion", "")); ops.AddAdditionalCapability(MobileCapabilityType.App, Config.GetConfigSetting("AppiumApp", "")); ops.AddAdditionalCapability(MobileCapabilityType.BrowserName, Config.GetConfigSetting("AppiumBrowserName", "")); ops.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, "120");//unsure if this is enough/too much ops.AddAdditionalCapability(MobileCapabilityType.Orientation, Config.GetConfigSetting("AppiumOrientation", "PORTRAIT")); var uri = Config.GetConfigSetting("AppiumServerUri", "http://127.0.01:4723/wd/hub"); switch (BrowserVendor) { case BrowserDriverEnumeration.Windows: RawWebDriver = new WindowsDriver <IWebElement>(new Uri(uri), ops); break; case BrowserDriverEnumeration.Android: RawWebDriver = new AndroidDriver <IWebElement>(new Uri(uri), ops); break; case BrowserDriverEnumeration.IOS: RawWebDriver = new IOSDriver <IWebElement>(new Uri(uri), ops); break; } }
public AutomationFactory(IAutomationConfiguration config = null) { if (config == null) { Configuration = new Config(); } else { Configuration = config; } }
private DriverOptions GetDesiredCapabilities(IAutomationConfiguration config) { DriverOptions result = config.SauceLabsBrowser switch { "IE" => new InternetExplorerOptions(), "Chrome" => new ChromeOptions(), _ => new FirefoxOptions(), }; string[] usernameKey = config.SauceLabsKey.Split(':'); if (usernameKey.Length != 2) { throw new Exception(string.Format("SauceLabsKey found in config file is not as expected. Expected username:key in the value attribute")); } result.AddAdditionalCapability("username", usernameKey[0]); result.AddAdditionalCapability("accessKey", usernameKey[1]); result.AddAdditionalCapability("platform", config.SauceLabsPlatform); return(result); }
public ReportUploader(IAutomationConfiguration configuration) { Configuration = configuration; SessionKey = Guid.NewGuid().ToString(); ApplicationId = ApplicationId.isNull() ? configuration.ApplicationUnderTest : ApplicationId; }
public BrowserDriver(IAutomationConfiguration configuration, BrowserDriverEnumeration browserVendor = BrowserDriverEnumeration.Firefox) { //add default screen size //add ability for custom settings in config //Add 'uri' for remote execution var uri = Config.GetConfigSetting("SeleniumHubUrl"); switch (browserVendor) { case BrowserDriverEnumeration.Chrome: var chromeOps = new ChromeOptions(); chromeOps.AddArgument("--start-maximized"); chromeOps.AddArgument("--disable-extensions"); Browser = new ChromeDriver("./", chromeOps); DriverType = "Chrome"; break; case BrowserDriverEnumeration.ChromeRemote: var chromeROps = new ChromeOptions(); chromeROps.AddArgument("--start-maximized"); chromeROps.AddArgument("--disable-extensions"); Browser = new RemoteWebDriver(new Uri(uri), chromeROps); DriverType = "Chrome"; CodePagesEncodingProvider.Instance.GetEncoding(437); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ((RemoteWebDriver)Browser).FileDetector = new LocalFileDetector(); break; case BrowserDriverEnumeration.Firefox: var ffOps = new FirefoxOptions(); ffOps.AddArgument("--start-maximized"); ffOps.AddArgument("--disable-extensions"); Browser = new FirefoxDriver("./", ffOps); DriverType = "FireFox"; break; case BrowserDriverEnumeration.FirefoxRemote: var ffROps = new FirefoxOptions(); ffROps.AddArgument("--start-maximized"); ffROps.AddArgument("--disable-extensions"); Browser = new RemoteWebDriver(new Uri(uri), ffROps); DriverType = "FireFox"; CodePagesEncodingProvider.Instance.GetEncoding(437); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ((RemoteWebDriver)Browser).FileDetector = new LocalFileDetector(); break; case BrowserDriverEnumeration.IE: var ieOps = new InternetExplorerOptions(); //ieOps.AddAdditionalCapability("--start-maximized"); //ieOps.AddAdditionalCapability("--disable-extensions"); Browser = new InternetExplorerDriver(ieOps); DriverType = "IE"; break; case BrowserDriverEnumeration.IERemote: var ieROps = new InternetExplorerOptions(); //ieROps.AddAdditionalCapability("--start-maximized"); //ieROps.AddAdditionalCapability("--disable-extensions"); Browser = new RemoteWebDriver(new Uri(uri), ieROps); DriverType = "IE"; break; case BrowserDriverEnumeration.Edge: var edgeOps = new EdgeOptions(); //edgeOps.AddAdditionalCapability("--start-maximized"); //edgeOps.AddAdditionalCapability("--disable-extensions"); Browser = new EdgeDriver(edgeOps); DriverType = "Edge"; break; case BrowserDriverEnumeration.EdgeRemote: var edgeROps = new EdgeOptions(); //edgeROps.AddAdditionalCapability("--start-maximized"); //edgeROps.AddAdditionalCapability("--disable-extensions"); Browser = new RemoteWebDriver(new Uri(uri), edgeROps); DriverType = "Edge"; break; case BrowserDriverEnumeration.SauceLabs: var capabilities = GetDesiredCapabilities(configuration); var url = new Uri("http://" + configuration.SauceLabsKey + "@ondemand.saucelabs.com:80/wd/hub"); Browser = new RemoteWebDriver(url, capabilities); CodePagesEncodingProvider.Instance.GetEncoding(437); Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); ((RemoteWebDriver)Browser).FileDetector = new LocalFileDetector(); break; } }