本文整理汇总了Python中robot.libraries.BuiltIn.BuiltIn.close_window方法的典型用法代码示例。如果您正苦于以下问题:Python BuiltIn.close_window方法的具体用法?Python BuiltIn.close_window怎么用?Python BuiltIn.close_window使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类robot.libraries.BuiltIn.BuiltIn
的用法示例。
在下文中一共展示了BuiltIn.close_window方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: close_popup
# 需要导入模块: from robot.libraries.BuiltIn import BuiltIn [as 别名]
# 或者: from robot.libraries.BuiltIn.BuiltIn import close_window [as 别名]
def close_popup():
"""
Closes a popup window that was opened with "Open Popup"
"""
seleniumlib = BuiltIn().get_library_instance('Selenium2Library')
if not hasattr(seleniumlib, 'main_window'):
raise UsageError('Popups must be opened with the same Selenium2Library'
' instance before they can be closed')
#This overrides any modal creation (e.g. "are you sure?")
seleniumlib.execute_javascript('window.onbeforeunload = function() {}')
browser = seleniumlib._current_browser()
logger.debug('Closing window: %s' % browser.current_window_handle)
seleniumlib.close_window()
logger.debug('Switching to window: %s' % seleniumlib.main_window)
browser.switch_to_window(seleniumlib.main_window)