/// <summary> /// Gets the default <see cref="ICommandExecutor"/>. The <see cref="ICommandExecutor"/> also defines the routes for the Quamotion WebDriver next to the standard <c>WebDriver</c> routes. /// </summary> /// <returns> /// The default command executor to use when automating mobile applications /// </returns> internal static TypedHttpCommandExecutor GetDefaultCommandExecutor() { if (defaultCommandExecutor == null) { var commandInfo = new W3CWireProtocolCommandInfoRepository(); commandInfo.AddAppCommands(); defaultCommandExecutor = new TypedHttpCommandExecutor(DefaultRemoteAddress, commandInfo); } return(defaultCommandExecutor); }
public SeleniumModule() { var repository = new W3CWireProtocolCommandInfoRepository(); var field = repository.GetType().BaseType.GetField("commandDictionary", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public); var commandDictionary = (Dictionary <string, CommandInfo>)field.GetValue(repository); After += AfterEach; Before += BeforeEach; foreach (var command in commandDictionary) { switch (command.Value.Method) { case CommandInfo.GetCommand: Get[command.Value.ResourcePath] = p => HandleCommand(command.Key, p); break; case CommandInfo.PostCommand: Post[command.Value.ResourcePath] = p => { var body = Request.Body.AsString(); var parameters = JObject.Parse(body).ToObject <Dictionary <string, object> >(); return(HandleCommand(command.Key, p, parameters)); }; break; case CommandInfo.DeleteCommand: Delete[command.Value.ResourcePath] = p => { var body = Request.Body.AsString(); if (body == null || body.Trim().Length == 0) { body = "{}"; } var parameters = JObject.Parse(body).ToObject <Dictionary <string, object> >(); return(HandleCommand(command.Key, p, parameters)); }; break; } } }
public static void AddAppiumCommands(W3CWireProtocolCommandInfoRepository commandInfoRepository) { commandInfoRepository.TryAddCommand( DriverCommand.CloseApp, new CommandInfo("POST", @"/session/{sessionId}/appium/app/close")); }