D:\Python27\Lib\site-packages\robotframework_selenium2library-1.1.0-py2.7.egg\Selenium2Library\locators (根据自身情况而定)
中的windowmanager.py 增加了方法
def select_by_handle(self, browser, toHandle):
browser.switch_to_window(toHandle)
def get_window_handles(self, browser):
return [ window_info[0] for window_info in self._get_window_infos(browser) ]
def get_current_window_handle(self, browser):
return browser.get_current_window_handle()
D:\Python27\Lib\site-packages\robotframework_selenium2library-1.1.0-py2.7.egg\Selenium2Library\keywords
中的_browsermanagement.py 增加如下方法
def select_window_by_handle(self, locator=None):
self._window_manager.select_by_handle(self._current_browser(), locator)
def get_window_handles(self):
"""Returns and logs handles of all windows known to the browser."""
return self._log_list(self._window_manager.get_window_handles(self._current_browser()))
def get_current_window_handle(self):
"""Returns and logs handle of current window known to the browser."""
return self._log_list(self._window_manager.get_current_window_handle(self._current_browser()))
==============================分割线==================================
按上述添加上,然后可以使用新添加的关键字了。
@{b} get window handles //@{b}变量保存当前所有的窗口。@符号表示这个变量是集合。
Select window by handle ${b[1]}//这个是取变量b里面的第二个窗口。(下标从0开始)。