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


Python WindowManager.get_window_ids方法代码示例

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


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

示例1: test_get_window_ids

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_ids [as 别名]
    def test_get_window_ids(self):
        manager = WindowManager()
        browser = self._make_mock_browser({'id': 'win1', 'name': 'win1', 'title': "Title 1", 'url': 'http://localhost/page1.html'},
            {'id': 'win2', '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_ids(browser), ['win1', 'win2', 'undefined'])
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:9,代码来源:test_windowmanager.py

示例2: test_get_window_ids

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import get_window_ids [as 别名]
    def test_get_window_ids(self):
        manager = WindowManager()
        browser = self._make_mock_browser(
            {"id": "win1", "name": "win1", "title": "Title 1", "url": "http://localhost/page1.html"},
            {"id": "win2", "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_ids(browser), ["win1", "win2", "undefined"])
开发者ID:ekasteel,项目名称:robotframework-selenium2library,代码行数:11,代码来源:test_windowmanager.py

示例3: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
        | Open Browser        | http://yahoo.com  | ie       | 2nd conn |
        | Location Should Be  | http://yahoo.com  |          |
        | 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.
开发者ID:konshow,项目名称:robotframework-selenium2library,代码行数:69,代码来源:_browsermanagement.py

示例4: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
        | Open Browser        | http://yahoo.com  | ie       | 2nd conn |
        | Location Should Be  | http://yahoo.com  |          |
        | 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):
开发者ID:Hi-Fi,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例5: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
        | Open Browser        | http://yahoo.com  | ie       | 2nd conn |
        | Location Should Be  | http://yahoo.com  |          |
        | 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):
开发者ID:binken,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py


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