Monorail Project: chromedriver Issues People Development process History Sign in
New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Issue 1315 |switch_to.window| does not visually switch tabs
Starred by 9 users Reported by, Jan 28 2016 Back to list
Status: Fixed
Last visit > 30 days ago
Closed: Mar 27

Sign in to add a comment
Issue Description:

With multiple tabs open |switch_to.window| does not visually switch tabs. |Webdriver.current_window_handle| is in fact switched, just not visually.

This is testing against Chrome 49.0.2618.8 dev (64-bit) on Ubuntu 14.04 with ChromeDriver 2.20.353124.

Steps to reproduce (if relevant, you MUST provide a simplified html page or
link to public site):

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
import time

driver = webdriver.Chrome()

driver.get('data:text/html,<a href="">Click me</a>')
tag = driver.find_element_by_tag_name('a')

# Build action to open link in new tab using ctrl-shift-click.
action = ActionChains(driver)

# Open two more tabs.


# Attempt to switch to the middle (obscured) tab.
print driver.current_window_handle
print driver.current_window_handle

Labels: Needs-Feedback

Window focus is out of the scope of chromedriver. Also, the specs says "In accordance with the focus section of the [html51] specification, commands are unaffected by whether the operating system window has focus or not."

Is there any reason/test scenario you want the window focus?
Please let us know.

Comment 2 by, Jan 28 2016
I am interested in simulating long lived sessions by loading multiple tabs and iterating though them in order to measure browser performance and memory statistics similar to the project for Firefox.

Bringing a tab into focus is an important part of this measurement as having focus potentially affects the memory overhead and performance. Currently this is supported by the marionette driver for Firefox.
I am also running into this issue. I can't see anything that is going on in the first window until I close the 2nd window that comes up. There is no way to visually focus back on the first window. I know you quoted from the webdriver spec but isn't webdriver's goal to emulate user behavior as closely as possible? This directly goes against that philosophy. 
I don't believe this has anything to do with operating system window focus - isn't the tab that's visible in Chrome solely up to Chrome?

The problem is that switching Chrome windows using switch_to seems to switch tabs internally, but that change is not reflected visually. According to driver.current_window_handle, the switched-to window is active, but that's not reflected visually in the Chrome instance launched by the chromedriver.

My use case is for remote control of the browser rather than for testing. I want to be able to switch between tabs programmatically, and currently it's impossible - I have to run multiple instances of Chrome and prod the window manager to switch between them, which is not ideal. Any testing that involves any human verification and switching tabs will have the same problem though.
Project Member Comment 5 by, Mar 24
The following revision refers to this bug:

commit 299aebf56a81ec56601da42c4db26d0e78e030b7
Author: samuong <>
Date: Fri Mar 24 23:01:31 2017

[chromedriver] Make tabs visible when switching to windows/tabs.

BUG= chromedriver:1315 

Cr-Commit-Position: refs/heads/master@{#459589}


Project Member Comment 6 by, Mar 27
Labels: -Needs-Feedback ChromeDriver-2.29
Status: Fixed
Fix will soon be released in chromedriver v2.29 .
Project Member Comment 7 by, Mar 31
Labels: OS-All Pri-3
Do I have access to ActivateWebView as an Selenium End User?  I have tests that require reading the dom on a window that does not have focus.
Sign in to add a comment