title: Selenium: switch tab in RemoteWebDriver with C#
body: <p>Currently, I'm trying to run my Selenium tests on Safari using Selenium Grid and RemoteWebDriver. This is my setup:</p>
  
  <ul>
  <li>Mac OS Sierra 10.12.6 as a machine for running tests.</li>
  <li>Selenium server 3.5.3.</li>
  <li>Safari 11.</li>
  <li>C# Selenium WebDriver and Selenium Support (latest version).</li>
  </ul>
  
  <p>I'm using port forwarding on my host OS (Windows 10) to forward requests to Mac, running on my Virtual Machine. On my Mac I have Selenium Grid hub, which I run like this:</p>
  
  <pre><code>java -jar selenium-server-standalone-3.5.3.jar -role hub -port 4723
  </code></pre>
  
  <p>Also, there is a node:</p>
  
  <pre><code>java -jar selenium-server-standalone-3.5.3.jar -role node -hub http://10.0.2.15:4723/grid/register
  </code></pre>
  
  <p>In code, I start my driver like this:</p>
  
  <pre><code>SafariOprions options = new SafariOptions();
  IWebDriver driver = new RemoteWebDriver(new Uri(hubURL), options.ToCapabilities());
  </code></pre>
  
  <p>My tests are running fine with current setup. But when it comes to clicking a link with attribute <code>target='_blank'</code> I'm starting to face some troubles. For other drivers, which I run locally, I can switch tab without any trouble: I'm getting <code>driver.WindowHandles</code> before I click a link, then I click a link and again retrieve Window Handles to compare with previous handles. After that I use <code>driver.SwitchTo().Window(newHandle)</code> and everything is ok.</p>
  
  <p>But when it comes to RemoteWebDriver (or SafariDriver from Apple, I cannot say more precisely) I'm always getting only one Window Handle, even if the new tab is opened and i can see it.</p>
  
  <p>I'm trying to avoid switching tab with "Command + T" as one of solutions suggested, because my tests are meant to be run on all browsers (Chrome, Firefox, Opera, Edge, Safari) and this wont work.</p>
  
  <p><strong>UPDATE:</strong> I've tried running Chrome and other browsers in Selenium Grid via RemoteWebDriver and I can say that this is not an issue of RemoteWebDriver. Next, I've installed Visual Studio for Mac and rewrite several things to run my tests without Selenium Grid, just using this code:</p>
  
  <pre><code>//if memory serves, just like this
  SafariOptions options = new SafariOptions();
  SafariDriver driver = new SafariDriver(options);
  </code></pre>
  
  <p>But, unfortunately, this didn't help. Driver navigated me to the page, clicked the link and opened a new tab, but without any switch. When I checked for <code>driver.WindowHandles</code> I've only got one, although there was two visible tabs. Neither <code>driver.SwitchTo().ActiveElement</code> nor <code>driver.SwitchTo().Frame(hardcoded_frame_name)</code> doesn't seem to work. Pretty long waits (for 60 seconds after opening the link and another one after that) aren't working too. Now I think that this is really a bug and I will try to report this to Apple as soon as I can.</p>
  
  <p>But for now, maybe someone has a fancy workaround for this?</p>