I would like to simulate a user pressing shift-enter in a text area. Here is the code I am working with:
var driver = new FirefoxDriver();
driver.Navigate().GoToUrl("http://pagewithtextarea");
var textarea = driver.FindElement(By.Id("myTextArea"));
//Send text
textarea.SendKeys("hello world!");
If I want to simulate pressing the enter button I can say:
textarea.SendKeys(Keys.Enter);
How could I simulate pressing shift and enter at the same time?
Simpler than I expected. Since SendKeys takes a string, and the static constants on Keys are all strings they can simply be concatenated together like this:
textarea.SendKeys(Keys.Shift + Keys.Enter);
for me, on c# only this variation works:
actions.KeyDown(Keys.Control);
actions.SendKeys("a");
actions.KeyUp(Keys.Control);
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