1、在\ Python27\Lib\site-packages\Selenium2Library\locators下:找到windowmanager.py文件。增加如下脚本:
def select_by_handle(self,browser,toHandle):
browser.switch_to_window(toHandle)
def get_window_handle(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()
*:\Python27\Lib\site-packages\Selenium2Library\keywords:找到_browsermanagement.py文件。
@keyword
def select_window_by_handle(self,locator=None):
self._window_manager.select_by_handle(self.drivers.current,locator)
@keyword
def get_window_handles(self):
return self._log_list(self._window_manager.get_window_handles(self.drivers.current))
@keyword
def get_current_window_handle(self):
return self._log_list(self._window_manager.get_current_window_handle(self.drivers.current))