static void Main()
{
IWebDriver driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://google.com");
IWebElement body = driver.FindElement(By.TagName("body"));
body.SendKeys(Keys.Control + "t");
}
This is the code that I am trying to use to open a new tab and its not working, I am not getting any errors nothing, the driver opens Google and thats all.... I have searched a lot and found many tutorials even videos where people are using the exact same code and it works for them, but for me it doesnt and I can't figure it out...
I tried sending Keys.Shift + "t" to the search field and it works, it writes a capital T in the field
I have also tried
Actions act = new Actions(driver);
act.KeyDown(Keys.Control).SendKeys("t").Perform();
And it still does not work, but again if I change Keys.Control to Keys.Shift it writes, seems like nothing that involves Keys.Control is working!!
Edit: I have tried running the code with a IE Driver and it worked there, it opens new tab, but it does not open new tabs on Chrome?
Selenium is an open-source Web UI automation testing suite. It was developed by Jason Huggins in 2004 as an internal tool at Thought Works. It supports automation across different browsers, platforms, and programming languages which includes Java, Python, C#, etc.
Conclusion: > Selenium WebDriver supports various programming languages like Java, Python, C#, Ruby, Perl, PHP, JavaScript, R, Objective-C and Haskell.
Webdriver++ is a C++ client library for Selenium Webdriver which you have to install and have the following feature support: Chainable commands. Value-like objects compatible with STL containers.
For Java, there is large support available online, as most of the professionals are using Selenium with Java. Rank wise Java is among the top 3 most popular languages, C# is not. On the other hand for C# if you stuck at any point then it would be quite difficult to get help from the online community.
Thanks for the answers! I did it with JavaScript.
((IJavaScriptExecutor)driver).ExecuteScript("window.open();");
Looks like it's a "feature" of the chrome driver.
https://bugs.chromium.org/p/chromedriver/issues/detail?id=581
This is a limitation in the way we simulate keyboard input in ChromeDriver. Keys get sent directly to the render process, bypassing the browser process. So any keyboard shortcut handlers in the browser process will not be invoked by sendKeys().
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