In one of my automated tests I need to press Ctrl+V in text box to paste text in it. But I can't do that. I'm using Selenium WebDriver for .net v. 2.35.0.0. Here is my code, it does not work. It presses Ctrl and then V, but text not gets pasted in the box:
IWebDriver webDriver = new InternetExplorerDriver();
webDriver.Navigate().GoToUrl(@"C:\Users\us\Documents\Visual Studio 2012\Projects\SeleniumTests\SeleniumTests\test.html");
var el = webDriver.FindElement(By.XPath(".//*[@id='fld']"));
el.Click();
Actions builder = new Actions(webDriver);
builder.KeyDown(el, Keys.LeftControl).Perform();
builder.SendKeys(el, "v").Perform();
builder.KeyUp(el, Keys.LeftControl).Perform();
webDriver.Quit();
Update: OS: Windows Server 2012, x64 Browser: IE10
Here's what I would suggest:
IWebDriver webDriver = new InternetExplorerDriver();
webDriver.Navigate().GoToUrl(@"C:\Users\us\Documents\Visual Studio 2012\Projects\SeleniumTests\SeleniumTests\test.html");
var el = webDriver.FindElement(By.XPath(".//*[@id='fld']"));
el.Click();
el.SendKeys(Keys.CONTROL+ "v");
webDriver.Quit();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With