New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 9 users
Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Mar 2017



Sign in to add a comment
|switch_to.window| does not visually switch tabs
Reported by ericr...@gmail.com, Jan 28 2016 Back to list
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="https://google.com">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)
action.key_down(Keys.CONTROL).key_down(Keys.SHIFT).click(tag).key_up(Keys.SHIFT).key_up(Keys.CONTROL)

# Open two more tabs.
action.perform()
action.perform()

time.sleep(1)

# Attempt to switch to the middle (obscured) tab.
print driver.current_window_handle
driver.switch_to.window(driver.window_handles[1])
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." https://w3c.github.io/webdriver/webdriver-spec.html

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


Comment 2 by ericr...@gmail.com, 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 areweslimyet.com 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. 
Comment 4 by al...@signiq.com, Mar 15 2017
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 bugdroid1@chromium.org, Mar 24 2017
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/299aebf56a81ec56601da42c4db26d0e78e030b7

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

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

BUG= chromedriver:1315 

Review-Url: https://codereview.chromium.org/2751253005
Cr-Commit-Position: refs/heads/master@{#459589}

[modify] https://crrev.com/299aebf56a81ec56601da42c4db26d0e78e030b7/chrome/test/chromedriver/session_commands.cc

Project Member Comment 6 by gmanikpure@chromium.org, Mar 27 2017
Labels: -Needs-Feedback ChromeDriver-2.29
Owner: samu...@chromium.org
Status: Fixed
Fix will soon be released in chromedriver v2.29 .
Project Member Comment 7 by gmanikpure@chromium.org, Mar 31 2017
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