Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Performing keyboard strokes "Ctrl + A" "Ctrl + C" and "Ctrl + V" on text field with selenium C#

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#.

like image 741
Arpan Buch Avatar asked Oct 17 '25 14:10

Arpan Buch


1 Answers

[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();
}
like image 171
Arpan Buch Avatar answered Oct 19 '25 03:10

Arpan Buch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!