/// <summary> /// Adds an additional capability to the Chrome Driver /// </summary> /// <param name="name">the name of the capabilitty to add</param> /// <param name="value">The value to set for the capability</param> public void AddAdditionalCapability(string name, object value) { try { Options.AddAdditionalCapability(name, value); } catch (Exception ex) { switch (BaseSettings.DebugLevel) { case EnumConsoleDebugLevel.Human: Console.Out.WriteLine("Unable to add the capability {0} | Value: {1}", name, value); break; case EnumConsoleDebugLevel.NotSpecified: case EnumConsoleDebugLevel.Message: Console.Out.WriteLine(ex.Message); break; case EnumConsoleDebugLevel.StackTrace: Console.Out.WriteLine(ex.Message); Console.Out.WriteLine(ex.StackTrace); break; } } }
/// <summary> /// Adds a series of additional capabilities to the Chrome Options object from the app.config file /// </summary> private void AddAdditionalCapabilities() { try { var capabilityList = Chrome.CapabilityList; if (capabilityList != null && capabilityList.Contains(",")) { var list = capabilityList.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); foreach (string item in list) { string[] setting = item.Split(new string[] { "=", "|" }, StringSplitOptions.RemoveEmptyEntries); string name = setting[0]; Type valueType = Type.GetType(setting[2]); var objValue = Convert.ChangeType(setting[1], valueType); Options.AddAdditionalCapability(name, objValue); } } } catch (Exception ex) { switch (BaseSettings.DebugLevel) { case EnumConsoleDebugLevel.Human: Console.Out.WriteLine("Driver was unable to load the capabilities from the config file."); Console.Out.WriteLine("Please investigate the changes you have made to your config file."); break; case EnumConsoleDebugLevel.NotSpecified: case EnumConsoleDebugLevel.Message: Console.Out.WriteLine(ex.Message); break; case EnumConsoleDebugLevel.StackTrace: Console.Out.WriteLine(ex.Message); Console.Out.WriteLine(ex.StackTrace); break; } } }