简介
Robot Framework是一款python编写的功能自动化测试框架。具备良好的可扩展性,支持关键字驱动,可以同时测试多种类型的客户端或者接口,可以进行分布式测试执行。主要用于轮次很多的验收测试和验收测试驱动开发(ATDD)。
环境搭建
需要安装的东西比较多,建议按我的步骤来,避免踩坑和浪费时间
-
安装Robot framework
直接在cmd中pip安装就可
命令:pip install robotframework -
安装Robot framework-ride和Wxpython
(下面步骤适合pip下载慢的,当时用别的电脑,没配置pip镜像,下载快的直接pip安装,忽略下面步骤)
这里需要注意,首先,在cmd中输入pip install robotframework-ride ,安装完ride后,会自动安装其它依赖的库,比如接下来我们要安装的wxPython,但是wxPython很大,有20M左右,在线安装需要很长时间,我们记住wxPython下载时的版本,然后去https://pypi.org/project/wxPython/4.0.7.post2/#files 找到对应的版本下载
下载完成后,将下载的whl文件放到python的Scripts文件夹下,打开cmd,进入该文件夹,输入pip install wxPython-4.0.7.post2-cp38-cp38-win_amd64.whl(改成自己的文件名)
我这里是anaconda下的
安装完Wxpython后,继续输入pip install robotframework-ride安装其他依赖
- 安装Robot framework-selenium2library
直接pip安装
验证安装
运行ride
打开cmd,进入前面提到的Scripts目录(一般在python环境的根目录,比如用的anaconda就在anaconda文件夹下),输入 python ride.py ,如果成功打开如下界面,则安装成功
可能的报错
在运行ride过程中,如果报错
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 54.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 55.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 56.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 57.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 58.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 59.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 60.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 61.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 62.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 63.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 67.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 68.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 69.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 70.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 71.
Creating librarykeywords database to "C:\Users\Administrator\AppData\Roaming\RobotFramework\ride\librarykeywords.db"
Traceback (most recent call last):
File "F:\anaconda\lib\site-packages\robotide\application\application.py", line 58, in OnInit
self.frame = RideFrame(self, self._controller)
File "F:\anaconda\lib\site-packages\robotide\ui\mainframe.py", line 175, in __init__
self._init_ui()
File "F:\anaconda\lib\site-packages\robotide\ui\mainframe.py", line 279, in _init_ui
self.tree = Tree(self, self.actions,
File "F:\anaconda\lib\site-packages\robotide\ui\tree.py", line 86, in __init__
self._images = TreeImageList()
File "F:\anaconda\lib\site-packages\robotide\ui\images.py", line 42, in __init__
TestCaseController: _TreeImage(self, 'robot.png'),
File "F:\anaconda\lib\site-packages\robotide\ui\images.py", line 80, in __init__
self.normal = self._get_image(image_list, normal)
File "F:\anaconda\lib\site-packages\robotide\ui\images.py", line 91, in _get_image
img = wx.Image(path, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
wx._core.wxAssertionError: C++ assertion "strcmp(setlocale(LC_ALL, NULL), "C") == 0" failed at ..\..\src\common\intl.cpp(1579) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!
OnInit returned false, exiting...
Error in atexit._run_exitfuncs:
wx._core.wxAssertionError: C++ assertion "GetEventHandler() == this" failed at ..\..\src\common\wincmn.cpp(478) in wxWindowBase::~wxWindowBase(): any pushed event handlers must have been removed
解决办法
打开报错中的application.py文件,修改application.py中 self._initial_locale = wx.Locale(wx.LANGUAGE_ENGLISH)
改为:
self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)后,ride可正常打开。