Selenium2Library中新增多窗口处理的关键字

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开始)。



转载于:https://www.cnblogs.com/rf-bear/p/5556451.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值