ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

RobotFramework--API高级网页跳转小练习

2021-11-03 21:32:39  阅读:195  来源: 互联网

标签:handle get -- self RobotFramework current window 跳转 browser


**

一.58同城小案例

**
1.今天我们来试试,在ride中,是怎么实现网页跳转的。
我们先来找一个小案例来试试。
案例:58租房:http://bj.58.com
登录58同城>>点击租房>>选择区域>>选择租金>>进行筛选
Get Window Handles:获取窗口的句柄 Select Window By Handle:切换到新窗口
我们就直接上图吧大家可以自己动手试试。
在这里插入图片描述
2.在这里会有一个问题,那就是Select Window By Handle,没有,需要大家自己去手动的配置一下文件,用编辑器打开在,注意格式。
1:在D:\install\python\python\Lib\site-packages\SeleniumLibrary\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()在这里插入图片描述

2:在D:\install\python\python\Lib\sitepackages\SeleniumLibrary\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): “”“Returns and logs handles of all windows known to the browser.”"" return self._log_list(self._window_manager.get_window_handles(self.drivers.current)) @keyword 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.drivers.current))在这里插入图片描述

3:从新启动ride.py才能正常加载。

二.QQ注册页面小案例。

1:表单跳转
案例:https://qzone.qq.com/
登录qq邮箱>>跳转表单>>填充用户密码>>主界面操作
Select Frame:选择表单
在这里插入图片描述
2.我们可以在dos下执行rf脚本。
1:找到python中的Scripts目录进入,新建一个pybot.bat文件
2:在pybot.bat文件中添加下面的命令
3:在dos窗口输入命令执行
执行整个项目下的所有用例: pybot 项目路径
在这里插入图片描述

标签:handle,get,--,self,RobotFramework,current,window,跳转,browser
来源: https://blog.csdn.net/xuxu_boke/article/details/121130334

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有