当前位置: 首页>>代码示例>>Python>>正文


Python WindowManager.get_window_titles方法代码示例

本文整理汇总了Python中Selenium2Library.locators.WindowManager.get_window_titles方法的典型用法代码示例。如果您正苦于以下问题:Python WindowManager.get_window_titles方法的具体用法?Python WindowManager.get_window_titles怎么用?Python WindowManager.get_window_titles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Selenium2Library.locators.WindowManager的用法示例。


在下文中一共展示了WindowManager.get_window_titles方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_window_titles

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_titles [as 别名]
    def test_get_window_titles(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_titles(browser), ['Title 1', 'Title 2', 'Title 3'])
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:9,代码来源:test_windowmanager.py

示例2: test_get_window_titles

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_titles [as 别名]
    def test_get_window_titles(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_titles(browser), ["Title 1", "Title 2", "Title 3"])
开发者ID:ekasteel,项目名称:robotframework-selenium2library,代码行数:11,代码来源:test_windowmanager.py

示例3: _BrowserManagementKeywords

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_titles [as 别名]

#.........这里部分代码省略.........
        | ${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}       |
        | ${width} | ${height}= | Get Window Size |
        | Should Be Equal | ${width}  | ${800}    |
        | Should Be Equal | ${height} | ${600}    |
        """
        return self._current_browser().set_window_size(width, height)

    def get_window_position(self):
        """Returns current window position as `x` then `y`.

        Example:
        | ${x} | ${y}= | Get Window Position |
开发者ID:konshow,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例4: _BrowserManagementKeywords

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_titles [as 别名]

#.........这里部分代码省略.........
        | ${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.

        If the window is found, all subsequent commands use that window, until
        this keyword is used again. If the window is not found, this keyword fails.
        
        By default, when a locator value is provided,
        it is matched against the title of the window and the
        javascript name of the window. If multiple windows with
        same identifier are found, the first one is selected.

        Special locator `main` (default) can be used to select the main window.

        It is also possible to specify the approach Selenium2Library should take
开发者ID:Hi-Fi,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例5: _BrowserManagementKeywords

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_titles [as 别名]

#.........这里部分代码省略.........
        | ${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.

        If the window is found, all subsequent commands use that window, until
        this keyword is used again. If the window is not found, this keyword fails.
        
        By default, when a locator value is provided,
        it is matched against the title of the window and the
        javascript name of the window. If multiple windows with
        same identifier are found, the first one is selected.

        Special locator `main` (default) can be used to select the main window.

        It is also possible to specify the approach Selenium2Library should take
开发者ID:binken,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py


注:本文中的Selenium2Library.locators.WindowManager.get_window_titles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。