3

How to simply want to input a value in a text box , select the complete text from the text box using "Ctrl+a" , then copy it using Ctrl + c" and then Paste it in the same box with "Ctrl + v" using Selenium + C#.

Axifive
  • 1,117
  • 2
  • 20
  • 30
Arpan Buch
  • 1,290
  • 4
  • 19
  • 41

1 Answers1

11
[FindsBy(How = How.Id, Using = "search-criteria")]
public IWebElement txtProductSearch1 = null

public void copypaste(string strCopy)
{ 
    txtProductSearch1.Click();
    txtProductSearch1.Clear();
    txtProductSearch1.SendKeys(strCopy);
    txtProductSearch1.SendKeys(Keys.Control + "a"); //a in smaller case
    txtProductSearch1.SendKeys(Keys.Control + "c"); // c in smaller case
    txtProductSearch1.Clear();
    txtProductSearch1.SendKeys(Keys.Control + "v"); // v in smaller case
    btnProductSearch1.Click();
}
Sam Holder
  • 31,788
  • 13
  • 99
  • 173
Arpan Buch
  • 1,290
  • 4
  • 19
  • 41