Exemplo n.º 1
0
 /// <summary>
 /// Waits until the <see cref="AppDriver"/> is ready.
 /// </summary>
 /// <param name="appDriver">
 /// The <see cref="AppDriver"/> on which to executor the command.
 /// </param>
 public static void WaitUntilReady(this AppDriver appDriver)
 {
     while (!appDriver.IsReady())
     {
         Thread.Sleep(1000);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Dismisses the the keyboard.
 /// </summary>
 /// <param name="appDriver">
 /// The <see cref="AppDriver"/> on which to executor the command.
 /// </param>
 public static void DismissKeyboard(this AppDriver appDriver)
 {
     appDriver.ExecuteCommand(AppDriverCommand.DismissKeyboard, new Dictionary <string, object>()
     {
         { AppDriverCommand.SessionId, appDriver.SessionId }
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Clears the text of the active text field.
 /// </summary>
 /// <param name="appDriver">
 /// The <see cref="AppDriver"/> on which to executor the command.
 /// </param>
 public static void ClearText(this AppDriver appDriver)
 {
     appDriver.ExecuteCommand(AppDriverCommand.ClearText, new Dictionary <string, object>()
     {
         { AppDriverCommand.SessionId, appDriver.SessionId }
     });
 }
Exemplo n.º 4
0
        /// <summary>
        /// Executes a command on the given <see cref="AppDriver"/>
        /// </summary>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <param name="name">
        /// The name of the command.
        /// </param>
        /// <param name="parameters">
        /// The parameters of the command.
        /// </param>
        /// <returns>
        /// The response of the execution.
        /// </returns>
        private static Response ExecuteCommand(this AppDriver appDriver, string name, Dictionary <string, object> parameters)
        {
            var command  = new Command(appDriver.SessionId, name, parameters);
            var response = appDriver.GetCommandExecutor().Execute(command);

            return(response);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Executes a command on the given <see cref="AppDriver"/>
        /// </summary>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <param name="name">
        /// The name of the command.
        /// </param>
        /// <param name="jsonParameters">
        /// The parameters of the command.
        /// </param>
        /// <returns>
        /// The response of the execution.
        /// </returns>
        private static Response ExecuteCommand(this AppDriver appDriver, string name, string jsonParameters)
        {
            var command  = new Command(name, jsonParameters);
            var response = appDriver.GetCommandExecutor().Execute(command);

            return(response);
        }
Exemplo n.º 6
0
        public static Timeouts GetTimeouts(this AppDriver appDriver)
        {
            var response = appDriver.ExecuteCommand(AppDriverCommand.GetTimeouts, new Dictionary <string, object>()
            {
                { AppDriverCommand.SessionId, appDriver.SessionId }
            });

            return(GetValue <Timeouts>(response));
        }
Exemplo n.º 7
0
 /// <summary>
 /// Clicks on the device screen on the given absolute coordinate.
 /// </summary>
 /// <param name="appDriver">
 /// The <see cref="AppDriver"/> on which to execute the command.
 /// </param>
 /// <param name="x">
 /// The x component of the coordinate.
 /// </param>
 /// <param name="y">
 /// The y component of the coordinate.
 /// </param>
 public static void ClickByCoordinate(this AppDriver appDriver, int x, int y)
 {
     appDriver.ExecuteCommand(AppDriverCommand.ClickByCoordinate, new Dictionary <string, object>()
     {
         { AppDriverCommand.SessionId, appDriver.SessionId },
         { "x", x },
         { "y", y }
     });
 }
Exemplo n.º 8
0
        public static void Flick(this AppDriver appDriver, IWebElement element, Direction direction)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(element) as string;

            appDriver.ExecuteCommand(AppDriverCommand.FlickCoordinate, new Dictionary <string, object>()
            {
                { "element", elementId },
                { "direction", direction }
            });
        }
Exemplo n.º 9
0
        public static void ScrollToVisible(this AppDriver appDriver, IWebElement element)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(element) as string;

            appDriver.ExecuteCommand(AppDriverCommand.ScrollToVisible, new Dictionary <string, object>()
            {
                { AppDriverCommand.SessionId, appDriver.SessionId },
                { AppDriverCommand.ElementId, elementId },
            });
        }
Exemplo n.º 10
0
        public static object PerformOperation(this AppDriver appDriver, IWebElement webElement, string operation, Collection <object> arguments)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(webElement) as string;

            return(appDriver.ExecuteCommand(AppDriverCommand.PerformOperation, new Dictionary <string, object>
            {
                { AppDriverCommand.SessionId, appDriver.SessionId },
                { AppDriverCommand.ElementId, elementId },
                { "operation", operation },
                { "args", arguments }
            }).Value);
        }
Exemplo n.º 11
0
        public static void SetProperty(this AppDriver appDriver, IWebElement element, string name, string value)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(element) as string;

            appDriver.ExecuteCommand(AppDriverCommand.SetProperty, new Dictionary <string, object>()
            {
                { AppDriverCommand.SessionId, appDriver.SessionId },
                { AppDriverCommand.ElementId, elementId },
                { AppDriverCommand.PropertyName, name },
                { AppDriverCommand.PropertyValue, value },
            });
        }
Exemplo n.º 12
0
        /// <summary>
        /// Scrolls until an element with the marked contition is visible.
        /// </summary>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <param name="element">
        /// The element on which to swipe.
        /// </param>
        /// <param name="xpath">
        /// the xpath condition to stop scrolling.
        /// </param>
        public static void ScrollUpTo(this AppDriver appDriver, IWebElement element, string xpath)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(element) as string;

            appDriver.ExecuteCommand(AppDriverCommand.ScrollTo, new Dictionary <string, object>()
            {
                { AppDriverCommand.SessionId, appDriver.SessionId },
                { AppDriverCommand.ElementId, elementId },
                { "value", xpath },
                { "using", "xpath" },
                { "direction", "Down" }
            });
        }
Exemplo n.º 13
0
        public static void FlickCoordinate(this AppDriver appDriver, IWebElement element, int x, int y, int xOffset, int yOffset, int speed)
        {
            var remoteWebElementType = typeof(RemoteWebElement);
            var elementIdField       = remoteWebElementType.GetField("elementId", BindingFlags.Instance | BindingFlags.NonPublic);
            var elementId            = elementIdField.GetValue(element) as string;

            appDriver.ExecuteCommand(AppDriverCommand.FlickCoordinate, new Dictionary <string, object>()
            {
                { "element", elementId },
                { "xCoordinate", x },
                { "yCoordinate", y },
                { "xoffset", xOffset },
                { "yoffset", yOffset },
                { "speed", speed },
            });
        }
Exemplo n.º 14
0
        public static string GetDeviceId(this AppDriver appDriver)
        {
            var capabilities = appDriver.Capabilities as ICapabilities;

            return(capabilities?.GetCapability("deviceId").ToString());
        }
Exemplo n.º 15
0
        /// <summary>
        /// Checks if the <see cref="AppDriver"/> is ready.
        /// </summary>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <returns>
        /// <see langword="true"/> if the <see cref="AppDriver"/> is ready;
        /// otherwise, returns <see langword="false"/>
        /// </returns>
        public static bool IsReady(this AppDriver appDriver)
        {
            var response = appDriver.ExecuteCommand(AppDriverCommand.IsReady, new Dictionary <string, object>());

            return((bool)response.Value);
        }
Exemplo n.º 16
0
 public static bool TestElementsByClassChain(this AppDriver appDriver, string value)
 {
     return(appDriver.TestElements(AppDriver.ClassChain, value));
 }
Exemplo n.º 17
0
 public static bool TestElementsByPredicateString(this AppDriver appDriver, string value)
 {
     return(appDriver.TestElements(AppDriver.PredicateString, value));
 }
Exemplo n.º 18
0
 public static ReadOnlyCollection <IWebElement> FindElementsByClassChain(this AppDriver appDriver, string value)
 {
     return(appDriver.FindElements(AppDriver.ClassChain, value));
 }
Exemplo n.º 19
0
 public static IWebElement FindElementByClassChain(this AppDriver appDriver, string value)
 {
     return(appDriver.FindElement(AppDriver.ClassChain, value));
 }
Exemplo n.º 20
0
 public static ReadOnlyCollection <IWebElement> FindElementsByPredicateString(this AppDriver appDriver, string value)
 {
     return(appDriver.FindElements(AppDriver.PredicateString, value));
 }
Exemplo n.º 21
0
 public static IWebElement FindElementByPredicateString(this AppDriver appDriver, string value)
 {
     return(appDriver.FindElement(AppDriver.PredicateString, value));
 }
Exemplo n.º 22
0
        /// <summary>
        /// Executes a command on the given <see cref="AppDriver"/>
        /// </summary>
        /// <typeparam name="T">
        /// The response type
        /// </typeparam>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <param name="name">
        /// The name of the command.
        /// </param>
        /// <param name="parameters">
        /// The parameters of the command.
        /// </param>
        /// <returns>
        /// The response of the execution.
        /// </returns>
        private static T ExecuteCommand <T>(this AppDriver appDriver, string name, Dictionary <string, object> parameters)
        {
            var command = new Command(appDriver.SessionId, name, parameters);

            return(appDriver.GetCommandExecutor().Execute <T>(command));
        }
Exemplo n.º 23
0
 /// <summary>
 /// Finds an element based on the marked meta tag. An element corresponds to the marked meta tag if the text property or the element id equals the tag value.
 /// </summary>
 /// <param name="appDriver">
 /// The <see cref="AppDriver"/> on which to executor the command.
 /// </param>
 /// <param name="marked">
 /// The marked meta tag.
 /// </param>
 /// <returns>
 /// The element matching the marked meta tag.
 /// </returns>
 public static IWebElement FindElementByMarked(this AppDriver appDriver, string marked)
 {
     return(appDriver.FindElement(By.XPath($"*[@marked='{marked}']")));
 }
Exemplo n.º 24
0
        /// <summary>
        /// Executes a command on the given <see cref="AppDriver"/>
        /// </summary>
        /// <typeparam name="T">
        /// The response type
        /// </typeparam>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <param name="name">
        /// The name of the command.
        /// </param>
        /// <param name="jsonParameters">
        /// The parameters of the command.
        /// </param>
        /// <returns>
        /// The response of the execution.
        /// </returns>
        private static T ExecuteCommand <T>(this AppDriver appDriver, string name, string jsonParameters)
        {
            var command = new Command(name, jsonParameters);

            return(appDriver.GetCommandExecutor().Execute <T>(command));
        }
Exemplo n.º 25
0
        /// <summary>
        /// Gets the <c>WebDriver</c> status
        /// </summary>
        /// <param name="appDriver">
        /// The <see cref="AppDriver"/> on which to executor the command.
        /// </param>
        /// <returns>
        /// The <c>WebDriver</c> status
        /// </returns>
        public static Status GetStatus(this AppDriver appDriver)
        {
            var response = appDriver.ExecuteCommand(AppDriverCommand.GetStatus, string.Empty);

            return(GetValue <Status>(response));
        }