2

Here is the code I have written But it is not working Any suggestion will be helpful

    IWebDriver driver = new ChromeDriver(@"C:\Selenium Automation\");
    driver.Navigate().GoToUrl("https://thealivecard.com/");

   Actions action = new Actions(driver);

    action
        .KeyDown(Keys.Control)
        .SendKeys("t")
        .KeyUp(Keys.Control)
        .Build().Perform(); 

    Console.WriteLine("new tab");
2
2

This is what I use to open and switch to a new tab in C#:

((IJavaScriptExecutor)driver).ExecuteScript("window.open();");
driver.SwitchTo().Window(driver.WindowHandles.Last());

The sending of keys seems to not always work. Depends on the page your are on, the focus state of the browser. While the JavaScript window.open always seems to work.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.