Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: How to send key combination in selenium's Keyboard.SendKeys

Tags:

c#

selenium

I'm using Selenium 2 on Windows to automate firefox. I tried to send 'Alt+Esc' to the browser to minimise it on start. However firefox keeps typing the '{%ESC}' in its address bar. What should I do? thanks.

using (driver = new FirefoxDriver(firefoxProfile))
{
    driver.Keyboard.SendKeys("{%ESC}");
}
like image 789
J Wang Avatar asked Dec 11 '22 02:12

J Wang


1 Answers

I use this to open a new window (with the keyboard input) and it works just fine

IWebDriver driver = new FirefoxDriver();                          
Actions action = new Actions(driver);
action.SendKeys(OpenQA.Selenium.Keys.Control + "n").Build().Perform();
like image 159
Rohan Ojha Avatar answered Dec 22 '22 03:12

Rohan Ojha