/// <summary> /// Reads the AppiumCapsMaqs section and appends to the driver options /// </summary> /// <param name="appiumOptions">The driver options to make this an extension method</param> /// <param name="capabilities">The mobile driver capabilities</param> /// <returns>The altered <see cref="DriverOptions"/> driver options</returns> public static void SetMobileOptions(this AppiumOptions appiumOptions, Dictionary <string, object> capabilities) { if (capabilities == null) { return; } foreach (KeyValuePair <string, object> keyValue in capabilities) { if (keyValue.Value != null && (!(keyValue.Value is string) || !string.IsNullOrEmpty(keyValue.Value as string))) { try { // Check if this is a Json string var jsonDictionary = JsonConvert.DeserializeObject <Dictionary <string, object> >(keyValue.Value as string); appiumOptions.AddAdditionalAppiumOption(keyValue.Key, jsonDictionary); } catch { // Not Json string so add as a normal string appiumOptions.AddAdditionalAppiumOption(keyValue.Key, keyValue.Value); } } } }