Esempio n. 1
0
        /// <summary>
        ///     Moves the cursor to a given x-y point and performs a click.
        ///     <para>Logs the event optionally.</para>
        /// </summary>
        /// <param name="y">...Description to be added...</param>
        /// <param name="logger">
        ///     The used <see cref="Logger" /> instance to display logged messages (<see cref="LogEventLevel" /> =
        ///     <see cref="LogEventLevel.Information" />) during
        ///     the method exeuction.
        /// </param>
        /// <param name="driver">The browser, that is represented by an <see cref="IWebDriver" /> instance.</param>
        /// <param name="x">...Description to be added...</param>
        public static void Click([NotNull] this IWebDriver driver, int x, int y, [CanBeNull] Logger logger = null)
        {
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }

            driver.Actions().MoveTo(x, y).Click().BuildAndPerform(logger);
        }
 /// <summary>
 /// perform right click on the element
 /// /// </summary>
 /// <example>Example code to wait for login Button: <code>
 /// this.Driver.RightClick(locator);
 /// </code></example>
 /// <param name="webDriver">The web driver.</param>
 /// <param name="locator">The locator.</param>
 /// <returns>true if it element present, false if not present.</returns>
 public static bool RightClick(this IWebDriver webDriver, ElementLocator locator)
 {
     try
     {
         webDriver.Actions().ContextClick(webDriver.GetElement(locator)).Build().Perform();
         return(true);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
Esempio n. 3
0
        /// <summary>
        ///     ...Description to be added...
        ///     <para>Logs the event optionally.</para>
        /// </summary>
        /// <param name="textToSend">...Description to be added...</param>
        /// <param name="logger">
        ///     The used <see cref="Logger" /> instance to display logged messages (<see cref="LogEventLevel" /> =
        ///     <see cref="LogEventLevel.Information" />) during
        ///     the method exeuction.
        /// </param>
        /// <param name="driver">The browser, that is represented by an <see cref="IWebDriver" /> instance.</param>
        public static void SendKeys([NotNull] this IWebDriver driver, [NotNull] string textToSend,
                                    [CanBeNull] Logger logger = null)
        {
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }
            if (textToSend == null)
            {
                throw new ArgumentNullException(nameof(textToSend));
            }

            logger?.Information($"Executing a SendKeys action with text {textToSend}.");

            driver
            .Actions()
            .SendKeys(textToSend)
            .BuildAndPerform(logger);
        }
Esempio n. 4
0
        /// <summary>
        ///     ...Description to be added...
        ///     <para>Logs the event optionally.</para>
        /// </summary>
        /// <param name="theKey">...Description to be added...</param>
        /// <param name="logger">
        ///     The used <see cref="Logger" /> instance to display logged messages (<see cref="LogEventLevel" /> =
        ///     <see cref="LogEventLevel.Information" />) during
        ///     the method exeuction.
        /// </param>
        /// <param name="driver">The browser, that is represented by an <see cref="IWebDriver" /> instance.</param>
        public static void KeyDownAndUp([NotNull] this IWebDriver driver, [NotNull] string theKey,
                                        [CanBeNull] Logger logger = null)
        {
            if (driver == null)
            {
                throw new ArgumentNullException(nameof(driver));
            }
            if (theKey == null)
            {
                throw new ArgumentNullException(nameof(theKey));
            }

            logger?.Information($"Executing a KeyDown and then a KeyUp action using the {theKey}.");

            driver
            .Actions()
            .KeyDown(theKey)
            .KeyUp(theKey)
            .BuildAndPerform(logger);
        }