Example #1
0
 public void ClearandSend(string value)
 {
     WrappedElement.Clear();
     _driver.WaitForPageLoad();
     WrappedElement.SendKeys(value);
     _driver.WaitForPageLoad();
 }
 internal void SetText(EventHandler <ElementActionEventArgs> settingValue, EventHandler <ElementActionEventArgs> valueSet, string value)
 {
     settingValue?.Invoke(this, new ElementActionEventArgs(this, value));
     WrappedElement.Clear();
     WrappedElement.SendKeys(value);
     valueSet?.Invoke(this, new ElementActionEventArgs(this, value));
 }
Example #3
0
 /// <summary>
 /// Send keys to the WebElement
 /// </summary>
 /// <param name="text">Text to be entered</param>
 public void SendKeys(string text)
 {
     if (String.IsNullOrEmpty(text))
     {
         Logger.Debug("Recived null or empty string for sendkeys, returning without proceeding.");
         return;
     }
     try
     {
         WrappedElement.SendKeys(text);
     }
     catch (StaleElementReferenceException e)
     {
         if (Driver != null && by != null)
         {
             Logger.Info("Caught exception {0}. Attempting to re-initialize element", e.Message);
             InitializeElement();
             WrappedElement.SendKeys(text);
         }
         else
         {
             throw;
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
         throw;
     }
     Logger.Info("Entered text '{0}' in the webelement : {1}", text, by);
 }
Example #4
0
        public UpWebElement SendKeys(string text)
        {
            UpDriver.WaitForPageReady();
            Log.GetLogger().Info($"Sending [{text}] to element [{ElementIdentifier}]");
            WrappedElement.SendKeys(text);

            return(this);
        }
Example #5
0
        protected virtual void DefaultUpload(string filePath)
        {
            Uploading?.Invoke(this, new ElementActionEventArgs(this));

            WrappedElement.SendKeys(filePath);

            Uploaded?.Invoke(this, new ElementActionEventArgs(this));
        }
Example #6
0
        public virtual void SelectByText(string value)
        {
            Selecting?.Invoke(this, new ComponentActionEventArgs(this, value));

            if (WrappedElement.Text != value)
            {
                WrappedElement.SendKeys(value);
            }

            Selected?.Invoke(this, new ComponentActionEventArgs(this, value));
        }
Example #7
0
        /// <summary>
        ///     The clear using key and send keys.
        /// </summary>
        /// <param name="keys">
        ///     The keys.
        /// </param>
        /// <param name="clearKey">
        ///     The clear key.
        /// </param>
        private void ClearUsingKeyAndSendKeys(string keys, string clearKey)
        {
            TestContext.WriteLine(string.Format(CultureInfo.InvariantCulture, "Clear text with {0} and type '{1}' to input '{2}'",
                                                clearKey, keys, Name));
            Enumerable.Range(0, Text.Length).ToList().ForEach(arg => WrappedElement.SendKeys(clearKey));

            WrappedElement.Clear();

            WrappedElement.SendKeys(keys);
            Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
        }
Example #8
0
 void Type(String text)
 {
     try
     {
         WaitUntilVisible(this.by);
         WrappedElement.SendKeys(text);
     }
     catch (Exception ex)
     {
         LoggerHandler.WtiteErrorToLog($"Text can't be enter in {name}", ex);
     }
 }
Example #9
0
        /// <summary>
        ///     Clears the and send one key.
        /// </summary>
        /// <param name="key">The key.</param>
        public void ClearAndSendOneKey(string key)
        {
            Logger.WriteLine(string.Format(CultureInfo.InvariantCulture, "Clear text and type '{0}' to input '{1}'", key, Name));

            if (Text.Length > 0)
            {
                WrappedElement.Clear();
            }

            WrappedElement.SendKeys(key);
            Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
        }
Example #10
0
        /// <summary>
        ///     Sends the keys not allowed.
        /// </summary>
        /// <param name="keys">The keys sequesnce.</param>
        /// <exception cref="System.ArgumentException">
        ///     The text of element + this.Name +  was changed from ' + initialTextValue +  to ' +.
        ///     keys + '.
        /// </exception>
        public void SendKeysNotAllowed(string keys)
        {
            var initialTextValue = Text;

            Logger.WriteLine(string.Format(CultureInfo.InvariantCulture, "Type '{0}' to input '{1}'", keys, Name));
            WrappedElement.SendKeys(keys);
            Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
            if (initialTextValue.Equals(keys))
            {
                throw new ArgumentException("The text of element" + Name + " was changed from '" + initialTextValue + " to '" + keys +
                                            "'");
            }
        }
Example #11
0
        /// <summary>
        ///     The clear using backspace and send keys.
        /// </summary>
        /// <param name="keys">The keys.</param>
        public override void ClearUsingBackspaceAndSendKeys(string keys)
        {
            TestContext.WriteLine(string.Format(CultureInfo.InvariantCulture,
                                                "Clear text with Backspace and type '{0}' to input '{1}'", keys, Name));
            Enumerable.Range(0, Text.Length).ToList().ForEach(arg => WrappedElement.SendKeys(Keys.Backspace));

            if (Text.Length > 0)
            {
                WrappedElement.Clear();
            }

            WrappedElement.SendKeys(keys.IndexOf(",", StringComparison.Ordinal) != -1 ? keys.Replace(",", string.Empty) : keys);
            Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
        }
Example #12
0
 public void ClearAndType(String text)
 {
     try
     {
         WaitUntilVisible(this.by);
         WrappedElement.Clear();
         WrappedElement.SendKeys(text);
         LoggerHandler.WriteToLog($"Enter the text in {name}");
     }
     catch (Exception ex)
     {
         LoggerHandler.WtiteErrorToLog($"Text can't be enter in {name}", ex);
     }
 }
Example #13
0
        internal void SetText(EventHandler <ComponentActionEventArgs <TDriverElement> > settingValue, EventHandler <ComponentActionEventArgs <TDriverElement> > valueSet, string value)
        {
            settingValue?.Invoke(this, new ComponentActionEventArgs <TDriverElement>(this, value));
            WrappedElement.Clear();
            WrappedElement.SendKeys(value);

            try
            {
                WrappedDriver.HideKeyboard();
            }
            catch
            {
                // ignore
            }

            valueSet?.Invoke(this, new ComponentActionEventArgs <TDriverElement>(this, value));
        }
Example #14
0
 /// <summary>
 ///     Clears the and send keys without focus lost.
 /// </summary>
 /// <param name="keys">The keys.</param>
 public void ClearAndSendKeysWithoutFocusLost(string keys)
 {
     WrappedElement.SendKeys(Keys.Control + "a");
     WrappedElement.SendKeys(Keys.Backspace);
     WrappedElement.SendKeys(keys);
 }
 public void Upload(string file)
 {
     WrappedElement.SendKeys(file);
 }
Example #16
0
 public void UploadFileFromPath(string path)
 {
     WrappedElement.SendKeys(path);
 }
Example #17
0
 /// <summary>
 ///     Sends the keys.
 /// </summary>
 /// <param name="keys">The keys.</param>
 public virtual void SendKeys(string keys)
 {
     Logger.WriteLine(string.Format(CultureInfo.InvariantCulture, "Type '{0}' to input '{1}'", keys, Name));
     WrappedElement.SendKeys(keys);
     Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
 }
Example #18
0
 /// <summary>
 ///     Clears the using backspace.
 /// </summary>
 public void ClearUsingBackspace()
 {
     Logger.WriteLine(string.Format(CultureInfo.InvariantCulture, "Clear input '{0}' with Backspace", Name));
     Enumerable.Range(0, Text.Length).ToList().ForEach(arg => WrappedElement.SendKeys(Keys.Backspace));
 }
Example #19
0
 /// <summary>
 ///     Sends the keys.
 /// </summary>
 /// <param name="keys">The keys.</param>
 public override void SendKeys(string keys)
 {
     TestContext.WriteLine(string.Format(CultureInfo.InvariantCulture, "Type '{0}' to input '{1}'", keys, Name));
     WrappedElement.SendKeys(keys.IndexOf(",", StringComparison.Ordinal) != -1 ? keys.Replace(",", string.Empty) : keys);
     Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
 }
 /// <summary>
 ///     Sends the one key.
 /// </summary>
 /// <param name="key">The key.</param>
 public void SendOneKey(string key)
 {
     WrappedElement.SendKeys(key);
     Waiter.Try(() => Browser.ExecuteJavaScript("$(arguments[0]).keyup();", OriginalWebElement));
 }
 public void SendKeys(string text)
 {
     Log.Information("'{0}' input in {1}", text, Name);
     WrappedElement.SendKeys(text);
 }
Example #22
0
 public void TypeText(string text)
 {
     Debug.WriteLine($"Text {text} is written in element with locator {By}");
     WrappedElement.Clear();
     WrappedElement.SendKeys(text);
 }
Example #23
0
 /// <summary>
 ///     Simulates typing text into the element.
 /// </summary>
 public void SendKeys(string text)
 {
     NgDriver.WaitForAngular();
     WrappedElement.SendKeys(text);
 }
Example #24
0
 public void SendKeys(string keys)
 {
     WrappedElement.SendKeys(keys);
 }
Example #25
0
 public void TypeText(string text)
 {
     WrappedElement.Clear();
     WrappedElement.SendKeys(text);
 }
Example #26
0
 /// <summary>
 ///     Simulates typing text into the element.
 /// </summary>
 /// <param name="text">The text to type into the element.</param>
 /// <remarks>
 ///     The text to be typed may include special characters like arrow keys,.
 ///     backspaces, function keys, and so on. Valid special keys are defined in.
 ///     <see cref="T:OpenQA.Selenium.Keys" />.
 /// </remarks>
 /// <seealso cref="T:OpenQA.Selenium.Keys" />
 public void SendKeys(string text)
 {
     Logger.WriteLine(string.Format(CultureInfo.InvariantCulture, "Type '{0}' to element '{1}'", text, Name));
     WrappedElement.SendKeys(text);
 }
 public void Paste()
 {
     WrappedElement.SendKeys(Keys.Control + 'v');
 }