Esempio n. 1
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 }
     });
 }
Esempio n. 2
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 }
     });
 }
Esempio n. 3
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));
        }
Esempio n. 4
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 }
     });
 }
Esempio n. 5
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 },
            });
        }
Esempio n. 6
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 }
            });
        }
Esempio n. 7
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 },
            });
        }
Esempio n. 8
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);
        }
Esempio n. 9
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" }
            });
        }
Esempio n. 10
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 },
            });
        }
Esempio n. 11
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);
        }
Esempio n. 12
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));
        }