/// <summary> /// Gets the full directory path of a Lynda.Test.Browsers.Browser.BrowserProduct /// that is installed on the system. /// </summary> /// <param name="browserProduct">Browser to get the full directory path of.</param> /// <returns>Full directory path of the installed browser, or null if the browser is not installed.</returns> public static string GetInstalledExePath(BrowserProduct browserProduct) { switch (browserProduct) { case BrowserProduct.IE: { return(IEBrowser.InstalledExePath); } case BrowserProduct.Chrome: { return(ChromeBrowser.InstalledExePath); } case BrowserProduct.Firefox: { return(FirefoxBrowser.InstalledExePath); } case BrowserProduct.Safari: { return(SafariBrowser.InstalledExePath); } default: throw new Exception(String.Format("Code not implemented yet: {0}", browserProduct.ToString())); } }
public static int GetSupportedVersion(BrowserProduct browserProduct) { switch (browserProduct) { case BrowserProduct.IE: { return(IEBrowser.SupportedExeMajorVersion); } case BrowserProduct.Chrome: { return(ChromeBrowser.SupportedExeMajorVersion); } case BrowserProduct.Firefox: { return(FirefoxBrowser.SupportedExeMajorVersion); } case BrowserProduct.Safari: { return(SafariBrowser.SupportedExeMajorVersion); } default: throw new Exception(String.Format("Code not implemented yet: {0}", browserProduct.ToString())); } }
/// <summary> /// Initializes a new instance of the Lynda.Test.Browsers.Browser class /// and opens a new browser window with the specified uri. /// </summary> /// <param name="product">The Lynda.Test.Browsers.Browser.BrowserProduct to open.</param> /// <param name="url">The default uri for the opened browser. If String.Empty then uri is the default uri for that browser.</param> /// <param name="killExisting">If TRUE, kills any open browser processes for the specified browser first.</param> public Browser(BrowserProduct product, string uri, bool killExisting) { if (product < BrowserProduct.IE || product > BrowserProduct.Safari) { throw new ArgumentOutOfRangeException("product", product, "Must be one of the following: IE, Firefox, Chrome or Safari"); } browserProduct = product; switch (browserProduct) { case BrowserProduct.IE: { ieBrowser = new IEBrowser(uri, killExisting); break; } case BrowserProduct.Chrome: { chromeBrowser = new ChromeBrowser(uri,killExisting); break; } case BrowserProduct.Firefox: { firefoxBrowser = new FirefoxBrowser(uri, killExisting); break; } case BrowserProduct.Safari: { safariBrowser = new SafariBrowser(uri, killExisting); break; } default: throw new Exception(String.Format("Code not implemented yet: {0}", product.ToString())); } }
/// <summary> /// Initializes a new instance of the Lynda.Test.Browsers.Browser class /// and opens a new browser window with the specified uri. /// </summary> /// <param name="product">The Lynda.Test.Browsers.Browser.BrowserProduct to open.</param> /// <param name="url">The default uri for the opened browser. If String.Empty then uri is the default uri for that browser.</param> /// <param name="killExisting">If TRUE, kills any open browser processes for the specified browser first.</param> public Browser(BrowserProduct product, string uri, bool killExisting) { if (product < BrowserProduct.IE || product > BrowserProduct.Safari) { throw new ArgumentOutOfRangeException("product", product, "Must be one of the following: IE, Firefox, Chrome or Safari"); } browserProduct = product; switch (browserProduct) { case BrowserProduct.IE: { ieBrowser = new IEBrowser(uri, killExisting); break; } case BrowserProduct.Chrome: { chromeBrowser = new ChromeBrowser(uri, killExisting); break; } case BrowserProduct.Firefox: { firefoxBrowser = new FirefoxBrowser(uri, killExisting); break; } case BrowserProduct.Safari: { safariBrowser = new SafariBrowser(uri, killExisting); break; } default: throw new Exception(String.Format("Code not implemented yet: {0}", product.ToString())); } }
/// <summary> /// Initializes Tests.AppConfig.AppSettings class. /// Reads specific key values from the appSettings section in the app.config file for the Tests.exe assembly. /// </summary> static AppSettings() { AssemblyName thisAssembly = Assembly.GetEntryAssembly().GetName(); configFileName = string.Format("{0}.exe.config", thisAssembly.Name); appSettings = null; try { appSettings = System.Configuration.ConfigurationManager.AppSettings; } catch (ConfigurationErrorsException e) { throw new Exception( string.Format("Failed to get application settings data from {0}.", configFileName), e); } //Browser string appSettingsBrowser = GetAppSettingsKeyValue("Browser"); try { browser = (BrowserProduct)Enum.Parse(typeof(BrowserProduct), appSettingsBrowser, true); } catch (ArgumentNullException e) { throw new Exception(string.Format("Application settings \"Browser\" key's value is null in {0}.", configFileName), e); } catch (ArgumentException e) { throw new Exception (string.Format("Application settings \"Browser\" key's value is not IE, Firefox, Chrome or Safari. Or the value is either an empty string or only contains white space. File:{0}.", configFileName), e); } if (browser < BrowserProduct.IE || browser > BrowserProduct.Safari) { throw new Exception(string.Format("Application settings \"Browser\" key's value is not IE, Firefox, Chrome or Safari. File:{0}.", configFileName)); } //Domain domain = GetAppSettingsKeyValue("Domain"); if (string.IsNullOrEmpty(domain)) { throw new Exception(string.Format("Application settings \"Domain\" key's value is null or empty. Value:{0}, File:{1}.", domain, configFileName)); } //MouseDefaultMoveTime string mouseDefaultMoveTimeToParse = GetAppSettingsKeyValue("MouseDefaultMoveTime"); if (string.IsNullOrEmpty(mouseDefaultMoveTimeToParse)) { throw new Exception(string.Format("Application settings \"MouseDefaultMoveTime\" key's value is null or empty. Value:{0}, File:{1}.", mouseDefaultMoveTimeToParse, configFileName)); } try { mouseDefaultMoveTime = Int32.Parse(mouseDefaultMoveTimeToParse); } catch (FormatException e) { throw new Exception(string.Format("Unable to convert application settings \"MouseDefaultMoveTime\" key's value to Int32. Value:{0}, File:{1}.", mouseDefaultMoveTimeToParse, configFileName), e); } catch (OverflowException e) { throw new Exception(string.Format("Unable to convert application settings \"MouseDefaultMoveTime\" key's value to Int32; value must be between {0} and {1}. Value:{2}, File:{3}.", Int32.MinValue, Int32.MaxValue, mouseDefaultMoveTimeToParse, configFileName), e); } if (mouseDefaultMoveTime < 1) { throw new Exception(string.Format("Application settings \"MouseDefaultMoveTime\" key's value must be > 0. Value:{0}, File:{1}.", mouseDefaultMoveTime, configFileName)); } //KeyboardDefaultKeyPressTime string keyboardDefaultKeyPressTimeToParse = GetAppSettingsKeyValue("KeyboardDefaultKeyPressTime"); if (string.IsNullOrEmpty(keyboardDefaultKeyPressTimeToParse)) { throw new Exception(string.Format("Application settings \"KeyboardDefaultKeyPressTime\" key's value is null or empty. Value:{0}, File:{1}.", keyboardDefaultKeyPressTimeToParse, configFileName)); } try { keyboardDefaultKeyPressTime = Int32.Parse(keyboardDefaultKeyPressTimeToParse); } catch (FormatException e) { throw new Exception(string.Format("Unable to convert application settings \"KeyboardDefaultKeyPressTime\" key's value to Int32. Value:{0}, File:{1}.", keyboardDefaultKeyPressTimeToParse, configFileName), e); } catch (OverflowException e) { throw new Exception(string.Format("Unable to convert application settings \"KeyboardDefaultKeyPressTime\" key's value to Int32; value must be between {0} and {1}. Value:{2}, File:{3}.", Int32.MinValue, Int32.MaxValue, keyboardDefaultKeyPressTimeToParse, configFileName), e); } if (keyboardDefaultKeyPressTime < 1) { throw new Exception(string.Format("Application settings \"KeyboardDefaultKeyPressTime\" key's value must be > 0. Value:{0}, File:{1}.", keyboardDefaultKeyPressTime, configFileName)); } }
/// <summary> /// Initializes a new instance of the Lynda.Test.Browsers.Browser class /// and opens a new browser window with the specified uri without killing any existing browser windows first. /// </summary> /// <param name="product">The Lynda.Test.Browsers.Browser.BrowserProduct to open.</param> /// <param name="uri">The default uri for the opened browser. If String.Empty then uri is the default uri for that browser.</param> public Browser(BrowserProduct product, string uri) : this(product, uri, false) { }
public static int GetSupportedVersion(BrowserProduct browserProduct) { switch (browserProduct) { case BrowserProduct.IE: { return IEBrowser.SupportedExeMajorVersion; } case BrowserProduct.Chrome: { return ChromeBrowser.SupportedExeMajorVersion; } case BrowserProduct.Firefox: { return FirefoxBrowser.SupportedExeMajorVersion; } case BrowserProduct.Safari: { return SafariBrowser.SupportedExeMajorVersion; } default: throw new Exception(String.Format("Code not implemented yet: {0}", browserProduct.ToString())); } }
/// <summary> /// Gets the full directory path of a Lynda.Test.Browsers.Browser.BrowserProduct /// that is installed on the system. /// </summary> /// <param name="browserProduct">Browser to get the full directory path of.</param> /// <returns>Full directory path of the installed browser, or null if the browser is not installed.</returns> public static string GetInstalledExePath(BrowserProduct browserProduct) { switch (browserProduct) { case BrowserProduct.IE: { return IEBrowser.InstalledExePath; } case BrowserProduct.Chrome: { return ChromeBrowser.InstalledExePath; } case BrowserProduct.Firefox: { return FirefoxBrowser.InstalledExePath; } case BrowserProduct.Safari: { return SafariBrowser.InstalledExePath; } default: throw new Exception(String.Format("Code not implemented yet: {0}", browserProduct.ToString())); } }
/// <summary> /// Initializes Tests.AppConfig.AppSettings class. /// Reads specific key values from the appSettings section in the app.config file for the Tests.exe assembly. /// </summary> static AppSettings() { AssemblyName thisAssembly = Assembly.GetEntryAssembly().GetName(); configFileName = string.Format("{0}.exe.config", thisAssembly.Name); appSettings = null; try { appSettings = System.Configuration.ConfigurationManager.AppSettings; } catch (ConfigurationErrorsException e) { throw new Exception( string.Format("Failed to get application settings data from {0}.",configFileName),e); } //Browser string appSettingsBrowser = GetAppSettingsKeyValue("Browser"); try { browser = (BrowserProduct)Enum.Parse(typeof(BrowserProduct),appSettingsBrowser,true); } catch (ArgumentNullException e) { throw new Exception(string.Format("Application settings \"Browser\" key's value is null in {0}.",configFileName),e); } catch (ArgumentException e) { throw new Exception (string.Format("Application settings \"Browser\" key's value is not IE, Firefox, Chrome or Safari. Or the value is either an empty string or only contains white space. File:{0}.",configFileName), e); } if (browser < BrowserProduct.IE || browser > BrowserProduct.Safari) { throw new Exception(string.Format("Application settings \"Browser\" key's value is not IE, Firefox, Chrome or Safari. File:{0}.",configFileName)); } //Domain domain = GetAppSettingsKeyValue("Domain"); if (string.IsNullOrEmpty(domain)) { throw new Exception(string.Format("Application settings \"Domain\" key's value is null or empty. Value:{0}, File:{1}.",domain,configFileName)); } //MouseDefaultMoveTime string mouseDefaultMoveTimeToParse = GetAppSettingsKeyValue("MouseDefaultMoveTime"); if (string.IsNullOrEmpty(mouseDefaultMoveTimeToParse)) { throw new Exception(string.Format("Application settings \"MouseDefaultMoveTime\" key's value is null or empty. Value:{0}, File:{1}.",mouseDefaultMoveTimeToParse,configFileName)); } try { mouseDefaultMoveTime = Int32.Parse(mouseDefaultMoveTimeToParse); } catch (FormatException e) { throw new Exception(string.Format("Unable to convert application settings \"MouseDefaultMoveTime\" key's value to Int32. Value:{0}, File:{1}.",mouseDefaultMoveTimeToParse,configFileName), e); } catch (OverflowException e) { throw new Exception(string.Format("Unable to convert application settings \"MouseDefaultMoveTime\" key's value to Int32; value must be between {0} and {1}. Value:{2}, File:{3}.",Int32.MinValue,Int32.MaxValue,mouseDefaultMoveTimeToParse,configFileName), e); } if (mouseDefaultMoveTime<1) { throw new Exception(string.Format("Application settings \"MouseDefaultMoveTime\" key's value must be > 0. Value:{0}, File:{1}.",mouseDefaultMoveTime, configFileName)); } //KeyboardDefaultKeyPressTime string keyboardDefaultKeyPressTimeToParse = GetAppSettingsKeyValue("KeyboardDefaultKeyPressTime"); if (string.IsNullOrEmpty(keyboardDefaultKeyPressTimeToParse)) { throw new Exception(string.Format("Application settings \"KeyboardDefaultKeyPressTime\" key's value is null or empty. Value:{0}, File:{1}.",keyboardDefaultKeyPressTimeToParse,configFileName)); } try { keyboardDefaultKeyPressTime = Int32.Parse(keyboardDefaultKeyPressTimeToParse); } catch (FormatException e) { throw new Exception(string.Format("Unable to convert application settings \"KeyboardDefaultKeyPressTime\" key's value to Int32. Value:{0}, File:{1}.",keyboardDefaultKeyPressTimeToParse,configFileName), e); } catch (OverflowException e) { throw new Exception(string.Format("Unable to convert application settings \"KeyboardDefaultKeyPressTime\" key's value to Int32; value must be between {0} and {1}. Value:{2}, File:{3}.",Int32.MinValue,Int32.MaxValue,keyboardDefaultKeyPressTimeToParse,configFileName), e); } if (keyboardDefaultKeyPressTime<1) { throw new Exception(string.Format("Application settings \"KeyboardDefaultKeyPressTime\" key's value must be > 0. Value:{0}, File:{1}.",keyboardDefaultKeyPressTime, configFileName)); } }