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


Python WindowManager.select方法代码示例

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


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

示例1: test_select_by_title_with_multiple_matches

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_title_with_multiple_matches(self):
        manager = WindowManager()
        browser = self._make_mock_browser({'name': 'win1', 'title': "Title 1", 'url': 'http://localhost/page1.html'},
            {'name': 'win2a', 'title': "Title 2", 'url': 'http://localhost/page2a.html'},
            {'name': 'win2b', 'title': "Title 2", 'url': 'http://localhost/page2b.html'})

        manager.select(browser, "title=Title 2")
        self.assertEqual(browser.current_window.name, 'win2a')
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:10,代码来源:test_windowmanager.py

示例2: test_select_by_url

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_url(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'})

        manager.select(browser, "url=http://localhost/page2.html")
        self.assertEqual(browser.current_window.name, 'win2')
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:10,代码来源:test_windowmanager.py

示例3: test_select_by_name_no_match

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_name_no_match(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' })

        with self.assertRaises(ValueError) as context:
            manager.select(browser, "name=win-1")
        self.assertEqual(context.exception.message, "Unable to locate window with name 'win-1'")
开发者ID:hali4ka,项目名称:robotframework-selenium2library,代码行数:12,代码来源:test_windowmanager.py

示例4: test_select_with_main_constant_locator

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_with_main_constant_locator(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'})

        manager.select(browser, "name=win2")
        self.assertEqual(browser.current_window.name, 'win2')
        manager.select(browser, "main")
        self.assertEqual(browser.current_window.name, 'win1')
开发者ID:IlfirinPL,项目名称:robotframework-MarcinKoperski,代码行数:12,代码来源:test_windowmanager.py

示例5: test_select_by_name_with_bad_case

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_name_with_bad_case(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"},
        )

        manager.select(browser, "name=Win2")
        self.assertEqual(browser.current_window.name, "win2")
开发者ID:ekasteel,项目名称:robotframework-selenium2library,代码行数:12,代码来源:test_windowmanager.py

示例6: test_select_by_title_with_multiple_matches

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_title_with_multiple_matches(self):
        manager = WindowManager()
        browser = self._make_mock_browser(
            {"name": "win1", "title": "Title 1", "url": "http://localhost/page1.html"},
            {"name": "win2a", "title": "Title 2", "url": "http://localhost/page2a.html"},
            {"name": "win2b", "title": "Title 2", "url": "http://localhost/page2b.html"},
        )

        manager.select(browser, "title=Title 2")
        self.assertEqual(browser.current_window.name, "win2a")
开发者ID:ekasteel,项目名称:robotframework-selenium2library,代码行数:12,代码来源:test_windowmanager.py

示例7: test_select_by_url_sloppy_match

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
    def test_select_by_url_sloppy_match(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"},
        )

        manager.select(browser, "url=   http://LOCALHOST/page2.html  ")
        self.assertEqual(browser.current_window.name, "win2")
开发者ID:ekasteel,项目名称:robotframework-selenium2library,代码行数:12,代码来源:test_windowmanager.py

示例8: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
        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 |
        """
        position = self._current_browser().get_window_position()
        return position['x'], position['y']

    def set_window_position(self, x, y):
        """Sets the position `x` and `y` of the current window to the specified values.

        Example:
        | Set Window Size | ${1000} | ${0}       |
        | ${x} | ${y}= | Get Window Position |
        | Should Be Equal | ${x}      | ${1000}   |
        | Should Be Equal | ${y}      | ${0}      |
        """
        return self._current_browser().set_window_position(x, y)

    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)
        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
        to find a window by specifying a locator strategy:

        | *Strategy* | *Example*                               | *Description*                        |
        | title      | Select Window `|` title=My Document     | Matches by window title              |
        | name       | Select Window `|` name=${name}          | Matches by window javascript name    |
        | url        | Select Window `|` url=http://google.com | Matches by window's current URL      |

        Example:
        | Click Link | popup_link | # opens new window |
开发者ID:konshow,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例9: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
            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
        to find a window by specifying a locator strategy:

        | *Strategy* | *Example*                               | *Description*                        |
        | title      | Select Window `|` title=My Document     | Matches by window title              |
        | name       | Select Window `|` name=${name}          | Matches by window javascript name    |
        | url        | Select Window `|` url=http://google.com | Matches by window's current URL      |

        Example:
        | Click Link | popup_link | # opens new window |
开发者ID:Hi-Fi,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例10: _BrowserManagementKeywords

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

#.........这里部分代码省略.........
            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
        to find a window by specifying a locator strategy:

        | *Strategy* | *Example*                               | *Description*                        |
        | title      | Select Window `|` title=My Document     | Matches by window title              |
        | name       | Select Window `|` name=${name}          | Matches by window javascript name    |
        | url        | Select Window `|` url=http://google.com | Matches by window's current URL      |

        Example:
        | Click Link | popup_link | # opens new window |
开发者ID:binken,项目名称:robotframework-selenium2library,代码行数:70,代码来源:_browsermanagement.py

示例11: test_select_with_invalid_prefix

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
 def test_select_with_invalid_prefix(self):
     manager = WindowManager()
     browser = mock()
     with self.assertRaises(ValueError) as context:
         manager.select(browser, "something=test1")
     self.assertEqual(context.exception.message, "Window locator with prefix 'something' is not supported")
开发者ID:hali4ka,项目名称:robotframework-selenium2library,代码行数:8,代码来源:test_windowmanager.py

示例12: test_select_with_null_browser

# 需要导入模块: from Selenium2Library.locators import WindowManager [as 别名]
# 或者: from Selenium2Library.locators.WindowManager import select [as 别名]
 def test_select_with_null_browser(self):
     manager = WindowManager()
     with self.assertRaises(AssertionError):
         manager.select(None, "name=test1")
开发者ID:hali4ka,项目名称:robotframework-selenium2library,代码行数:6,代码来源:test_windowmanager.py


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