[New] RobotFramework dream dry environment to build step

RobotFramework as the company can quickly landed the UI test automation a framework, but also very suitable for friends who just started to learn fast automated testing of automation, from the author plans to build step by step to complete automated testing to describe the whole process of its use.


Robot Framework environment to build step


Robot Framework is based on the Python language a framework for the development, set up as follows:

Robot Framework for early adopters of the new version of the familiar veteran or python familiar friends see the following simple steps of installation (detailed screenshots illustrate the content for the new entry friends)


Easy installation steps:

1. Install python3.7

2. Enter pip install robotframework dos command-line installation robotframework

3. Enter pip install Pypubsub == 3.3.0 dos command-line installation in Pypubsub

4. Enter the dos pip install command line installation wxPython wxPython == 4.0.3

5. Enter pip install robotframework-ride command-line installation in dos robotframework-ride

6. In the dos command input pip list to check whether the installation was successful

7. dos command input ride.py RIDE check for the main interface, such as can not appear, may be mounted to the python path \ scripts \ ride.py manually by double clicking


Detailed installation steps:

1. Install python3.7

2. Enter the online installation robotframework pip install robotframework in dos command



3. Enter the online installation Pypubsub dos command pip install Pypubsub == 3.3.0



4. 在线安装 wxPython 在dos命令中输入 pip install wxPython==4.0.3(截图略,与上截图类似)

5. 在线安装 robotframework-ride 在dos命令输入 pip install robotframework-ride ,安装过程中需要安装依赖,过程较慢(截图略,与上截图类似)

6. 在dos命令输入 pip list ,检查上述软件是否安装成功


5cb54517223f1.jpg


7. 在dos命令输入 ride.py 命令打开RIDE主界面



常见问题


1. 依赖相关问题

robotframework-ride 1.7.3.1 安装所使用的Pypubsub版本要求的兼容版本为3.3.0,如果太新,安装过程中会出现警告信息,但笔者实验后发现出现警告也可以使用,但还是建议大家使用所要求的兼容版本。

2. 偶发性的报错

由于笔者是软测培训相关的讲师,在教学过程中,学生安装时出现过如下截图的偶发性错误:



dos命令下错误信息:

C:\WINDOWS\system32>ride.py

1.Traceback (most recent call last):

File "d:\python\lib\site-packages\robotide\application\application.py", line 59, in OnInit

self._plugin_loader.enable_plugins()

File "d:\python\lib\site-packages\robotide\application\pluginloader.py", line 43, in enable_plugins

p.enable_on_startup()

File "d:\python\lib\site-packages\robotide\application\pluginconnector.py", line 52, in enable_on_startup

self.enable()

File "d:\python\lib\site-packages\robotide\application\pluginconnector.py", line 57, in enable

self._plugin.enable()

File "d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py", line 162, in enable

self._build_ui()

File "d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py", line 558, in _build_ui

self._build_notebook_tab()

File "d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py", line 734, in _build_notebook_tab

self.out = self._create_output_textctrl()

File "d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py", line 769, in _create_output_textctrl

font = self._create_font()

File "d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py", line 789, in _create_font

font=wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT)

wx._core.wxAssertionError: C++ assertion "wxFontEnumerator::IsValidFacename(font.GetFaceName())" failed at ....\src\msw\settings.cpp(301) in wxSystemSettingsNative::GetFont():

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


解决方案:

根据如上提示信息,找到 testrunnerplugin.py文件路径,如上是

d:\python\lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py

用pycharm等python代码编辑工具打开该py文件,编辑789行:

把 font=wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT) 改为 font=wx.SystemSettings.GetFont(wx.ANSI_FIXED_FONT)


3. 没有权限报错

在使用Text Edit区域编写代码完成,保存代码的时候会出现如下图报错:




错误信息:

Error in serializing 'C:\robotframeworkcode\newdream':

[Errno 13] Permission denied: 'C:\robotframeworkcode\newdream.'


解决方案:

问题的主因是Robot Framework的RIDE没有相关权限引起的。

强制关闭 Robot Framework 的RIDE界面后,找到 ride.py 文件的存放路径(python安装路径\Scripts\ride.py),

Windows 7 操作系统,右击 ride.py 文件 -- 选择 管理员取得所有权即可。

Windows 10操作系统,右击 ride.py 文件 -- 选择 共享 -- 特定用户 -- 选择自己登录Windows10的账号共享即可。


4. 离线安装

离线安装不会自动安装依赖类库,需要手动把相关依赖类库下载才可进行安装,笔者不推荐此安装方式。

如果在没有网络的环境下,使用离线安装环境,需要提前下载对应的类库安装文件,按如下顺序下载安装:

robotframework-3.1.1 、PyPubSub-3.3.0 、six-1.12.0、Pygments-2.3.1、robotframeworklexer-1.1、robotframework-ride-1.7.3.1

下载网站:https://pypi.org/

离线安装python类库步骤:

1)解压下载的类库软件

2)在dos命令中进入解压目录,输入 python setup.py install 安装


5. robotframework-excellibrary库暂时不支持

该库暂时不支持,没有解决方案,有相关方案的朋友可以反馈下。


    


在2019年之前,robotframework-ride的版本一直是1.5.2.1,是2016年1月份的版本,里面需要使用 wxPython2.8-win64-unicode-2.8.12.1-py27.exe,wxPython2.8只能安装在python2.7的环境上,导致如果想同时使用robot framework做测试且又需要python3环境编写python代码的小伙伴都需要在操作系统上安装两个python环境(2.7和3.7)。

2019年,robotframework-ride迎来的这次更新算是解决了此问题,从此只需要安装python3.6以上的python环境即可。参考文献robotframework官方文档:https://pypi.org/project/robotframework/#installation

Guess you like

Origin blog.51cto.com/14627097/2459020