Robot Framework 环境搭建

官方文档
http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html
前面部分遇到坑,可以直接移步到 下方 【基于anaconda安装】

python安装

https://www.python.org/
https://www.python.org/downloads/

image.png

官网太卡
直接到360软件管家去下吧
image.png

image.png

配置环境变量

查看一下是否生效
image.png

pip安装

下载安装py,保存为get-pip.py
https://bootstrap.pypa.io/get-pip.py

安装pip

pip 也配置到环境变量


pip路径
测试

配置镜像

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
image.png

参考 Python配置镜像源的三种方法:https://blog.csdn.net/weixin_45779095/article/details/120143727

安装RF

pip install robotframework==5.0
robot --version
安装RF

安装ride

pip install robotframework-ride
image.png

运行ride
直接运行ride.py

C:\Users\xxxx>ride.py
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 0.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 3.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 4.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 5.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 6.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 7.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 19.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 20.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 21.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 22.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 25.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 26.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 27.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 28.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 29.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 30.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 31.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 32.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 33.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 34.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 35.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 36.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 37.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 38.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 39.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 40.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 43.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 44.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 45.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 46.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 47.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 48.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 49.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 50.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 51.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 52.
<class 'robotide.preferences.configobj.UnreprError'> Parse error in value at line 53.
<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\xxxx\AppData\Roaming\RobotFramework\ride\librarykeywords.db"
Traceback (most recent call last):
  File "D:\xxxx\python3\lib\site-packages\robotide\application\application.py", line 58, in OnInit
    self.frame = RideFrame(self, self._controller)
  File "D:\xxxx\python3\lib\site-packages\robotide\ui\mainframe.py", line 175, in __init__
    self._init_ui()
  File "D:\xxxx\python3\lib\site-packages\robotide\ui\mainframe.py", line 279, in _init_ui
    self.tree = Tree(self, self.actions,
  File "D:\xxxx\python3\lib\site-packages\robotide\ui\tree.py", line 86, in __init__
    self._images = TreeImageList()
  File "D:\xxxx\python3\lib\site-packages\robotide\ui\images.py", line 42, in __init__
    TestCaseController: _TreeImage(self, 'robot.png'),
  File "D:\xxxx\python3\lib\site-packages\robotide\ui\images.py", line 80, in __init__
    self.normal = self._get_image(image_list, normal)
  File "D:\xxxx\python3\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

报错了,百度看到被人改了D:\xxxx\python3\lib\site-packages\robotide\application\application.py
换这一句
self._initial_locale = wx.Locale(wx.LANGUAGE_CHINESE_SIMPLIFIED)


image.png

不过依然报错

C:\Users\xxxx>ride.py
Traceback (most recent call last):
  File "D:\xxxx\python3\lib\site-packages\robotide\__init__.py", line 82, in main
    _run(inpath, not noupdatecheck, debug_console)
  File "D:\xxxx\python3\lib\site-packages\robotide\__init__.py", line 101, in _run
    from robotide.application import RIDE
  File "D:\xxxx\python3\lib\site-packages\robotide\application\__init__.py", line 16, in <module>
    from .application import RIDE, Project
  File "D:\xxxx\python3\lib\site-packages\robotide\application\application.py", line 51
    self._initial_locale = wx.Locale(wx.LANGUAGE_CHINESE_SIMPLIFIED)
                                                                   ^
TabError: inconsistent use of tabs and spaces in indentation


Use --help to get usage information.

缩进有问题
直接EDLE打开看看


image.png

缩进确实不对


image.png

修改后
self.locale = wx.Locale(wx.LANGUAGE_CHINESE_SIMPLIFIED)
image.png

出来界面没有汉化


image.png
image.png

依然有问题,python 3.8 与RF版本不兼容
要用python3.7
接下来用来安装python环境,可以安装多个python环境,方便切换python

基于anaconda安装

下载anaconda并安装,都是傻瓜式安装
https://www.anaconda.com/products/distribution

image.png

安装完后
image.png

点击它打开命令行窗口

#创建python3.7的环境
conda create --name testApp python==3.7.0

#查看创建的列表
conda env list
image.png

安装依赖

#robotframework
pip install robotframework==3.1.2
#UI
pip install wxPython
#ride
pip install robotframework-ride
#appium
pip install robotframework-appiumlibrary
#数据库
pip install robotframework-databaselibrary
#请求
pip install robotframework-requests
#selenium
pip install robotframework-seleniumlibrary

运行

ride.py
#正常了
image.png

可以开始学习开发工作了

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容