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

Unified Diff: chrome/test/webdriver/test/chromedriver.py

Issue 10854026: Added webdriver support for App v2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added test and addressed review comments. Created 8 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: chrome/test/webdriver/test/chromedriver.py
diff --git a/chrome/test/webdriver/test/chromedriver.py b/chrome/test/webdriver/test/chromedriver.py
index a22680dad93cf162eb63b7bcb436bdedbfd123ac..45c1d8ace7b9e1957ad925ece0b8fdc5e492a5aa 100644
--- a/chrome/test/webdriver/test/chromedriver.py
+++ b/chrome/test/webdriver/test/chromedriver.py
@@ -22,6 +22,7 @@ class _ViewType(object):
EXTENSION_POPUP = 2
EXTENSION_BG_PAGE = 3
EXTENSION_INFOBAR = 4
+ EXTENSION_PACKAGED_APP = 6
kkania 2012/08/09 22:04:49 is this the same thing as an app shell? Is there a
Danh Nguyen 2012/08/10 16:35:09 No it doesn't. Thanks Ken for pointing this out.
class WebDriver(RemoteWebDriver):
@@ -165,32 +166,12 @@ class Extension(object):
{'click_button': 'page_action'})
def get_bg_page_handle(self):
- """Returns the window handle for the background page.
-
- This handle can be used with |WebDriver.switch_to_window|.
-
- Returns:
- The window handle, or None if there is no background page.
- """
- bg_pages = filter(lambda view: view['type'] == _ViewType.EXTENSION_BG_PAGE,
- self._get_views())
- if len(bg_pages) > 0:
- return bg_pages[0]['handle']
- return None
+ """Returns the window handle for the background page."""
+ return self._get_handle(_ViewType.EXTENSION_BG_PAGE)
def get_popup_handle(self):
- """Returns the window handle for the open browser/page action popup.
-
- This handle can be used with |WebDriver.switch_to_window|.
-
- Returns:
- The window handle, or None if there is no popup open.
- """
- popups = filter(lambda view: view['type'] == _ViewType.EXTENSION_POPUP,
- self._get_views())
- if len(popups) > 0:
- return popups[0]['handle']
- return None
+ """Returns the window handle for the open browser/page action popup."""
+ return self._get_handle(_ViewType.EXTENSION_POPUP)
def get_infobar_handles(self):
"""Returns a list of window handles for all open infobars of this extension.
@@ -201,6 +182,26 @@ class Extension(object):
self._get_views())
return map(lambda view: view['handle'], infobars)
+ def get_packaged_app_handle(self):
+ """Returns the window handle for the packaged app."""
+ return self._get_handle(_ViewType.EXTENSION_PACKAGED_APP)
+
+ def _get_handle(self, type):
+ """Returns the window handle for the page of given type.
+
+ This handle can be used with |WebDriver.switch_to_window|.
+
+ Args:
+ type: The type of the window as defined in _ViewType.
+
+ Returns:
+ The window handle, or None if there is no page with the given type.
+ """
+ pages = filter(lambda view: view['type'] == type, self._get_views())
+ if len(pages) > 0:
+ return pages[0]['handle']
+ return None
+
def _get_info(self):
"""Returns a dictionary of all this extension's info."""
return self._execute(WebDriver._CHROME_GET_EXTENSION_INFO)['value']

Powered by Google App Engine
This is Rietveld 408576698