新tab窗口不能操作的解决方法

1)场景:

界面A:登录界面(或其他界面),操作后,弹出一个新tab页或新窗口界面

界面B(弹出一个新tab页或新窗口界面):不能被RF操作,如click,input等

2)原因:

界面的句柄仍然聚焦在界面A上,所以RF无法识别界面B。也就是无法识别界面B的元素,也就导致无法通过Xpath进行定位和界面操作

3)解决:

方法1:通过handle句柄完成

#假设此次有RF代码,且界面A操作完了
#接下来代码,是为了操作界面B
${handle_list}    Get Window Handles
Select Window    ${handle_list}[1]    #list从0开始即list[0],此次获取list[1] = 新tab窗口
Select Frame    //*[@id="frame_top"]    #新tab窗口,需要锁定frame。因为此时整个source page有多套html层级,需要锁定frame,再进行操作如click,input
click element    //*[@id="trade"]

方法2:通过 Select Window    NEW完成

#假设此次有RF代码,且界面A操作完了
#接下来代码,是为了操作界面B
Select Window    NEW
Select Frame    //*[@id="frame_top"]
click element    //*[@id="trade"]


Select Window 备注:
By default, the locator is matched against window handle, name, title, and URL. Matching is done in that order and the first matching window is selected.
The locator can specify an explicit strategy by using the format strategy:value (recommended) or strategy=value. Supported strategies are name, title, and url. These matches windows using their name, title, or URL, respectively. Additionally, default can be used to explicitly use the default strategy explained above.
If the locator is NEW (case-insensitive), the latest opened window is selected. It is an error if this is the same as the current window.
If the locator is MAIN (default, case-insensitive), the main window is selected.
If the locator is CURRENT (case-insensitive), nothing is done. This effectively just returns the current window handle.
If the locator is not a string, it is expected to be a list of window handles to exclude. Such a list of excluded windows can be got from Get Window Handles before doing an action that opens a new window.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值