K
K
kos_dev2017-03-15 22:32:06
C++ / C#
kos_dev, 2017-03-15 22:32:06

How to send key combination C# Selenium Webdriver?

How to send key combination C# Selenium Webdriver?
Maybe you didn't connect the addon. libraries, only OpenQA.Selenium is connected.
I want to close the active browser tab, the window.close() request does not respond to JS, I want to try sending the CTRL + W combination
. Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
kos_dev, 2017-03-20
@kos_dev

To close a window, you need to find out its Handle, then switch to it using SwitchTo (), and then do driver.Close () - this method will close the current open window, if it is the last one, an empty one will be opened in place of the closed one.

E
Evgeniy _, 2017-03-15
@GeneD88

IWebDriver driver = new FirefoxDriver();

Actions action=new Actions(driver);

action.SendKeys(OpenQA.Selenium.Keys.Control + "w").Build().Perform();

K
kvasek, 2017-03-18
@kvasek

Try like this.
driver.findElement( ... ).sendKeys(Keys.chord(Keys.CONTROL, "a"));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question