Click here to Skip to main content
15,746,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a program to run videos listed on my site for testing purpose and here what I need is to run videos in different tabs of the same browser window.

I have hundred video urls in the List<string> videoLinks = getVideoUrls();
and now what I need is to execute these videos 5 at a time.

ChromeDriver driver = new ChromeDriver();
            driver.Navigate().GoToUrl("" + videoLink);

If I go the above way then for all videos I will have to create a new ChromeDriver object. I want to use single chrome browser object.

I have tried this
IWebElement body = driver.FindElement(By.TagName("body"));
               body.SendKeys(Keys.Control + "t");

it only adds a new tab but not open a link there.
Please let me know how should I go around it. I have googled but couldn't find my solution so thought to ask for help from you geeks.

I would appreciate your response.
Updated 5-May-21 11:24am

Actions action = new Actions(_driver);

This will open IwebElement body in new tab.
Share this answer
I would add that this piece of code:

Actions action = new Actions(_driver);

will not release CTRL key in the keyboard what can cause openning new tab in same window if this piece of code is running in a loop.

So right version is:

Actions action = new Actions(_driver);
Share this answer
var driver = new ChromeDriver();
driver.FindElement(By.CssSelector("Body")).SendKeys(Keys.Control + "t");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900