Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7943751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:21:47+00:00 2026-06-04T00:21:47+00:00

When I click on a link in my test, it opens a new tab.

  • 0

When I click on a link in my test, it opens a new tab.
I want ChromeDriver to then focus on that tab. I have tried the following code to get ChromeDriver to change tabas using the ctrl+tab shortcut:

Actions builder = new Actions(driver);
builder.KeyDown(Keys.Control).KeyDown(Keys.Tab).KeyUp(Keys.Tab).KeyUp(Keys.Control);//switch tabs
IAction switchTabs = builder.Build();
switchTabs.Perform();

But this throws the following exception:

ekmLiveChat.tests.UITests.EndToEndTest.EndToEnd:
System.ArgumentException : key must be a modifier key (Keys.Shift, Keys.Control, or Keys.Alt)
Parameter name: key

Is there a way to switch tabs using ChromeDriver?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:21:49+00:00Added an answer on June 4, 2026 at 12:21 am

    As mentioned in my comment on your post, I’m not sure if the Chrome driver handles tabs the same way as it handles windows.

    This code works in Firefox when opening new windows, so hopefully it works in your case as well:

    public void SwitchToWindow(Expression<Func<IWebDriver, bool>> predicateExp)
    {
        var predicate = predicateExp.Compile();
        foreach (var handle in driver.WindowHandles)
        {
            driver.SwitchTo().Window(handle);
            if (predicate(driver))
            {
                return;
            }
        }
    
        throw new ArgumentException(string.Format("Unable to find window with condition: '{0}'", predicateExp.Body));
    }
    
    SwitchToWindow(driver => driver.Title == "Title of your new tab");
    

    (I hope my edits to the code for this answer didn’t introduce any errors…)

    Just make sure you don’t start looking for the new tab before Chrome has had the chance to open it 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test file that includes the following code. The page opens up
The following command selenium.click(link=Identify Awards); opens a popup however the the test does not
I want to do something like $('a.filter-link').click(function(e) { e.preventDefault(); var that = $(this), categoryId
I have a page called test.aspx and in that page, I have the following
i have a link <a id=cartLink href=https://site.foxycart.com/cart?cart=checkout >Test</a> when you click on this link
Heres my link: http://tinyurl.com/6j727e If you click on the link in test.php, it opens
Tried this: $('.link').click(function(e) { $.getScript('http://www.google.com/uds/api?file=uds.js&amp;v=1.0', function() { $('body').append('<p>GOOGLE API (UDS) is loaded</p>'); }); return
When i click a link im calling a servlet. When i click that link
I am trying to do the following: On link click: 1.) fade out an
i have created Array of Linkbutton and when user click on link button it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.