本文整理汇总了Python中Selenium2Library.locators.WindowManager.get_window_names方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.get_window_names方法的具体用法?Python WindowManager.get_window_names怎么用?Python WindowManager.get_window_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Selenium2Library.locators.WindowManager
的用法示例。
在下文中一共展示了WindowManager.get_window_names方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_window_names
# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_names [as 别名]
def test_get_window_names(self):
manager = WindowManager()
browser = self._make_mock_browser({'name': 'win1', 'title': "Title 1", 'url': 'http://localhost/page1.html'},
{'name': 'win2', 'title': "Title 2", 'url': 'http://localhost/page2.html'},
{'name': 'win3', 'title': "Title 3", 'url': 'http://localhost/page3.html'})
self.assertEqual(manager.get_window_names(browser), ['win1', 'win2', 'win3'])
示例2: test_get_window_names
# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_names [as 别名]
def test_get_window_names(self):
manager = WindowManager()
browser = self._make_mock_browser(
{"name": "win1", "title": "Title 1", "url": "http://localhost/page1.html"},
{"name": "win2", "title": "Title 2", "url": "http://localhost/page2.html"},
{"name": "win3", "title": "Title 3", "url": "http://localhost/page3.html"},
)
self.assertEqual(manager.get_window_names(browser), ["win1", "win2", "win3"])
示例3: _BrowserManagementKeywords
# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_names [as 别名]
#.........这里部分代码省略.........
| Switch Browser | 1 | # index |
| Page Should Contain | I'm feeling lucky | |
| Switch Browser | 2nd conn | # alias |
| Page Should Contain | More Yahoo! | |
| Close All Browsers | | |
Above example expects that there was no other open browsers when
opening the first one because it used index '1' when switching to it
later. If you aren't sure about that you can store the index into
a variable as below.
| ${id} = | Open Browser | http://google.com | *firefox |
| # Do something ... |
| Switch Browser | ${id} | | |
"""
try:
self._cache.switch(index_or_alias)
self._debug('Switched to browser with Selenium session id %s'
% self._cache.current.session_id)
except (RuntimeError, DataError): # RF 2.6 uses RE, earlier DE
raise RuntimeError("No browser with index or alias '%s' found."
% index_or_alias)
# Public, window management
def close_window(self):
"""Closes currently opened pop-up window."""
self._current_browser().close()
def get_window_identifiers(self):
"""Returns and logs id attributes of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_ids(self._current_browser()))
def get_window_names(self):
"""Returns and logs names of all windows known to the browser."""
values = self._window_manager.get_window_names(self._current_browser())
# for backward compatibility, since Selenium 1 would always
# return this constant value for the main window
if len(values) and values[0] == 'undefined':
values[0] = 'selenium_main_app_window'
return self._log_list(values)
def get_window_titles(self):
"""Returns and logs titles of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_titles(self._current_browser()))
def maximize_browser_window(self):
"""Maximizes current browser window."""
self._current_browser().maximize_window()
def get_window_size(self):
"""Returns current window size as `width` then `height`.
Example:
| ${width} | ${height}= | Get Window Size |
"""
size = self._current_browser().get_window_size()
return size['width'], size['height']
def set_window_size(self, width, height):
"""Sets the `width` and `height` of the current window to the specified values.
Example:
| Set Window Size | ${800} | ${600} |
示例4: _BrowserManagementKeywords
# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_names [as 别名]
#.........这里部分代码省略.........
| Switch Browser | 1 | # index |
| Page Should Contain | I'm feeling lucky | |
| Switch Browser | 2nd conn | # alias |
| Page Should Contain | More Yahoo! | |
| Close All Browsers | | |
Above example expects that there was no other open browsers when
opening the first one because it used index '1' when switching to it
later. If you aren't sure about that you can store the index into
a variable as below.
| ${id} = | Open Browser | http://google.com | *firefox |
| # Do something ... |
| Switch Browser | ${id} | | |
"""
try:
self._cache.switch(index_or_alias)
self._debug('Switched to browser with Selenium session id %s'
% self._cache.current.session_id)
except (RuntimeError, DataError): # RF 2.6 uses RE, earlier DE
raise RuntimeError("No browser with index or alias '%s' found."
% index_or_alias)
# Public, window management
def close_window(self):
"""Closes currently opened pop-up window."""
self._current_browser().close()
def get_window_identifiers(self):
"""Returns and logs id attributes of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_ids(self._current_browser()))
def get_window_names(self):
"""Returns and logs names of all windows known to the browser."""
values = self._window_manager.get_window_names(self._current_browser())
# for backward compatibility, since Selenium 1 would always
# return this constant value for the main window
if len(values) and values[0] == 'undefined':
values[0] = 'selenium_main_app_window'
return self._log_list(values)
def get_window_titles(self):
"""Returns and logs titles of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_titles(self._current_browser()))
def maximize_browser_window(self):
"""Maximizes current browser window."""
self._current_browser().execute_script(
"if (window.screen) { window.moveTo(0, 0); window.resizeTo(window.screen.availWidth, window.screen.availHeight); }")
def select_frame(self, locator):
"""Sets frame identified by `locator` as current frame.
Key attributes for frames are `id` and `name.` See `introduction` for
details about locating elements.
"""
self._info("Selecting frame '%s'." % locator)
element = self._element_find(locator, True, True, tag='frame')
self._current_browser().switch_to_frame(element)
def select_window(self, locator=None):
"""Selects the window found with `locator` as the context of actions.
示例5: _BrowserManagementKeywords
# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_names [as 别名]
#.........这里部分代码省略.........
| Switch Browser | 1 | # index |
| Page Should Contain | I'm feeling lucky | |
| Switch Browser | 2nd conn | # alias |
| Page Should Contain | More Yahoo! | |
| Close All Browsers | | |
Above example expects that there was no other open browsers when
opening the first one because it used index '1' when switching to it
later. If you aren't sure about that you can store the index into
a variable as below.
| ${id} = | Open Browser | http://google.com | *firefox |
| # Do something ... |
| Switch Browser | ${id} | | |
"""
try:
self._cache.switch(index_or_alias)
self._debug('Switched to browser with Selenium session id %s'
% self._cache.current.session_id)
except (RuntimeError, DataError): # RF 2.6 uses RE, earlier DE
raise RuntimeError("No browser with index or alias '%s' found."
% index_or_alias)
# Public, window management
def close_window(self):
"""Closes currently opened pop-up window."""
self._current_browser().close()
def get_window_identifiers(self):
"""Returns and logs id attributes of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_ids(self._current_browser()))
def get_window_names(self):
"""Returns and logs names of all windows known to the browser."""
values = self._window_manager.get_window_names(self._current_browser())
# for backward compatibility, since Selenium 1 would always
# return this constant value for the main window
if len(values) and values[0] == 'undefined':
values[0] = 'selenium_main_app_window'
return self._log_list(values)
def get_window_titles(self):
"""Returns and logs titles of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_titles(self._current_browser()))
def maximize_browser_window(self):
"""Maximizes current browser window."""
self._current_browser().execute_script(
"if (window.screen) { window.moveTo(0, 0); window.resizeTo(window.screen.availWidth, window.screen.availHeight); }")
def select_frame(self, locator):
"""Sets frame identified by `locator` as current frame.
Key attributes for frames are `id` and `name.` See `introduction` for
details about locating elements.
"""
self._info("Selecting frame '%s'." % locator)
element = self._element_find(locator, True, True, tag='frame')
self._current_browser().switch_to_frame(element)
def select_window(self, locator=None):
"""Selects the window found with `locator` as the context of actions.