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


Python BaseWindow.switch_to方法代码示例

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


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

示例1: test_switch_to_and_focus

# 需要导入模块: from firefox_puppeteer.ui.windows import BaseWindow [as 别名]
# 或者: from firefox_puppeteer.ui.windows.BaseWindow import switch_to [as 别名]
    def test_switch_to_and_focus(self):
        # force BaseWindow instance
        win1 = BaseWindow(self.marionette, self.browser.handle)

        # Open a new window (will be focused), and check states
        win2 = win1.open_window()

        # force BaseWindow instance
        win2 = BaseWindow(self.marionette, win2.handle)

        self.assertEquals(win2.handle, self.marionette.current_chrome_window_handle)
        self.assertEquals(win2.handle, self.puppeteer.windows.focused_chrome_window_handle)
        self.assertFalse(win1.focused)
        self.assertTrue(win2.focused)

        # Switch back to win1 without moving the focus, but focus separately
        win1.switch_to()
        self.assertEquals(win1.handle, self.marionette.current_chrome_window_handle)
        self.assertTrue(win2.focused)

        win1.focus()
        self.assertTrue(win1.focused)

        # Switch back to win2 by focusing it directly
        win2.focus()
        self.assertEquals(win2.handle, self.marionette.current_chrome_window_handle)
        self.assertEquals(win2.handle, self.puppeteer.windows.focused_chrome_window_handle)
        self.assertTrue(win2.focused)

        # Close win2, and check that it keeps active but looses focus
        win2.switch_to()
        win2.close()

        win1.switch_to()
开发者ID:luke-chang,项目名称:gecko-1,代码行数:36,代码来源:test_windows.py


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