做自动化测试首先要保证的就是用例覆盖面完整,而UI测试首先保证就是浏览器覆盖率问题,robot支持的火狐和谷歌浏览器、IE都很好,当然IE可能有一点问题,不过10、11切换的用问题不大。
目前用户大多用360浏览器进行上网,我们构建一下使360浏览器也能进行自动化测试,首先说一下原理,360浏览器是基于谷歌内核开发出来的浏览器,所以驱动也会识别该浏览器,因此可以添加自动化测试,至于搜狗浏览器目前正在研究其方式,他双核属于谷歌和IE加上自己开发的东西,驱动不明确。有点跑题了,等我研究搜狗浏览器以后会继续更新的。
说明:基于Selenium: 3.0.2
一、各浏览器webdriver
说明:
1. selenium中,firefox需要下载webdriver(geckodriver.exe)。
2. 360极速和360安全浏览器的内核是chrome拷贝两份chromedriver 2.20,可以重命名为 360sechromedriver。(本人实现两种浏览器,只介绍一种浏览器360急速和360安全原理一样)
注意,360浏览器会自动升级。请关闭自动升级。
目录:C:\Users\username\AppData\Roaming\360se6\Application\9.1.1.250\installer,找到chromeup.dll文件,删除或者重命名
二、增加代码支持让RIDE识别360浏览器
修改selenium\webdriver目录下__init__.py代码。
目录:C:\Python27\Lib\site-packages\selenium\webdriver
增加导入这个包的代码,一会写这段代码,初始化时候就可以找到该代码调用驱动了。
修改Selenium2Library\keywords下browsermanagement.py代码
目录:C:\Python27\Lib\site-packages\robotframework_selenium2library-1.8.1-py2.7.egg\Selenium2Library\keywords
代码段一:
首先把我们浏览器名字加入进去。
让ride识别
代码二:搜索def _make_chrome,增加两段代码
增加启动时引用360驱动的代码。
三、360浏览器的实现代码
目录:C:\Python27\Lib\site-packages\selenium\webdriver
文件1:__init__.py,可以为空,也可以增加说明文字。例如,作者,版本,功能等。
文件2:新建webdriver.py,实现360极速浏览器。代码如下:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
360安全浏览器类似:
这样就构建好了。打开ride浏览器填写 chrome360se就OK了。