Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Unified Diff: tools/telemetry/telemetry/core/backends/webdriver/webdriver_tab_list_backend.py

Issue 20672002: [telemetry] Add a webdriver backend with support for IE. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix errors after rebase. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/telemetry/core/backends/webdriver/webdriver_tab_list_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/webdriver/webdriver_tab_list_backend.py b/tools/telemetry/telemetry/core/backends/webdriver/webdriver_tab_list_backend.py
new file mode 100644
index 0000000000000000000000000000000000000000..a528d1774eae1cf7c0211c4a93839ec3b1c6b939
--- /dev/null
+++ b/tools/telemetry/telemetry/core/backends/webdriver/webdriver_tab_list_backend.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from telemetry.core.backends.webdriver import webdriver_tab_backend
+
+class WebDriverTabListBackend(object):
+ def __init__(self, browser_backend):
+ self._browser_backend = browser_backend
+ # Stores the window handles.
+ self._tab_list = []
+
+ def Init(self):
+ self._UpdateTabList()
+
+ def New(self, timeout=None):
+ # Webdriver API doesn't support tab controlling.
+ raise NotImplementedError()
+
+ def __iter__(self):
+ self._UpdateTabList()
+ return self._tab_list.__iter__()
+
+ def __len__(self):
+ self._UpdateTabList()
+ return len(self._tab_list)
+
+ def __getitem__(self, index):
+ self._UpdateTabList()
+ if len(self._tab_list) <= index:
+ raise IndexError('list index out of range')
+ return self._tab_list[index]
+
+ def _UpdateTabList(self):
+ window_handles = self._browser_backend.driver.window_handles
+ old_tab_list = self._tab_list
+ self._tab_list = []
+ for window_handle in window_handles:
+ tab = None
+ for old_tab in old_tab_list:
+ if old_tab.window_handle == window_handle:
+ tab = old_tab
+ break
+ else:
+ tab = webdriver_tab_backend.WebDriverTabBackend(
+ self._browser_backend, window_handle)
+ self._tab_list.append(tab)

Powered by Google App Engine
This is Rietveld 408576698