title: Selenium Java in Safari - Switch to new tab is not working
body: <p>I have the next situation:</p>
  
  <p>I'm running Automation in MacOS with Selenium in Safari.
  I want to take control over a new tab opened (Switch to a new tab in Safari)</p>
  
  <p>I'm able to do it with Chrome and Firefox, but in Safari does not work.</p>
  
  <p>The next code is what I'm using for that:</p>
  
  <pre><code>    //Store the parent window
      String parentWindow = driver.getWindowHandle();
  
      //Open a new Windows(Mailtrap)
      String a = "window.open('https://mailtrap.io/signin','_blank');";
      ((JavascriptExecutor)driver).executeScript(a);
  
  
      //Take control over new browser
      for(String handle: driver.getWindowHandles()){
          driver.switchTo().window(handle);
      }
  
      //Make the same actions over new window
      driver.manage().window().maximize();
  
      driver.switchTo().defaultContent();
  </code></pre>
  
  <p>After that...</p>
  
  <p>//Close window and back to the parent window</p>
  
  <pre><code>    driver.close();
      driver.switchTo().window(parentWindow);
      driver.switchTo().defaultContent();
  </code></pre>
  
  <p>As I told before: It works in Firefox, Chrome, IE11, but in Safari 12.0.3 this is the message when I do a manual click over a tab.</p>
  
  <p>"This Safari window is remotely controlled by an automated test."</p>
  
  <p>To interact with this Safari window, you need to stop the current automated test session.
  You should not use this window for normal web browsing.</p>
  
  <p>"Turn OFF All Automation" , "Stop Session", "Continue Session"</p>
  
  <p>Could anybody help me with this?</p>
  
  <p>PS: Develop --> Allow remote automation is selected.</p>