基于Python在MacOS上安装robotframework-ride

时间:2021-05-22

Robotframework是一个框架,是一个可以用于关键字测试驱动的框架。而RIDE(robotframework-ride)就是可以使得写robot测试用例更加方便快捷的IDE图形操作工具。

安装

因为是基于python的,所以其可以运行在多个操作系统上。这里主要介绍一下RIDE在MacOS上的使用方式。

OS版本

MacOS版本:10.13.2

wxpython

由于RIDE是基于wxpython的应用,所以首先需要保证wxpython已经得到了安装。安装命令如下:

安装命令:brew install wxpython

安装日志

liumiaocn:~ liumiao$ brew install wxpython==> Installing dependencies for wxpython: gdbm, readline, sqlite, python@2, jpeg, libpng, libtiff, wxmac==> Installing wxpython dependency: gdbm==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.15.high_sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring gdbm-1.15.high_sierra.bottle.tar.gz? /usr/local/Cellar/gdbm/1.15: 19 files, 569.8KB==> Installing wxpython dependency: readline==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.3_1.high_sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring readline-7.0.3_1.high_sierra.bottle.tar.gz==> CaveatsThis formula is keg-only, which means it was not symlinked into /usr/local,because macOS provides the BSD libedit library, which shadows libreadline.In order to prevent conflicts when programs look for libreadline we aredefaulting this GNU Readline installation to keg-only.For compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/readline/lib CPPFLAGS: -I/usr/local/opt/readline/include==> Summary? /usr/local/Cellar/readline/7.0.3_1: 46 files, 1.5MB==> Installing wxpython dependency: sqlite==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.24.0.high_sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring sqlite-3.24.0.high_sierra.bottle.tar.gz==> CaveatsThis formula is keg-only, which means it was not symlinked into /usr/local,because macOS provides an older sqlite3.If you need to have this software first in your PATH run: echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profileFor compilers to find this software you may need to set: LDFLAGS: -L/usr/local/opt/sqlite/lib CPPFLAGS: -I/usr/local/opt/sqlite/includeFor pkg-config to find this software you may need to set: PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig==> Summary? /usr/local/Cellar/sqlite/3.24.0: 11 files, 3.5MB==> Installing wxpython dependency: python@2==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.15_1.high_sierra.bottle.tar.gz######################################################################## 100.0%==> Pouring python@2-2.7.15_1.high_sierra.bottle.tar.gz==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-mana==> CaveatsPip and setuptools have been installed. To update them pip install --upgrade pip setuptoolsYou can install Python packages with pip install <package>They will install into the site-package directory /usr/local/lib/python2.7/site-packagesSee: https://docs.brew.sh/Homebrew-and-Python==> Summary? /usr/local/Cellar/python@2/2.7.15_1: 4,673 files, 82.8MB==> Installing wxpython dependency: jpeg==> Downloading https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gzcurl: (6) Could not resolve host: akamai.bintray.comError: Failed to download resource "jpeg"Download failed: https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gzWarning: Bottle installation failed: building from source.==> Downloading http:///Homebrew/homebrew-core/blob/master/Formula/wxpython.rb==> DependenciesRequired: python@2 ✔, wxmac ✔liumiaocn:~ liumiao$

暂定对应1:wxpython安装之后,目前的版本还缺少一个软连接才能正常动作,根据日志可以看到此次安装的wxpython版本为wxpython-3.0.2.0_1, 按照如下操作创建软连接即可

创建链接

liumiaocn:bin liumiao$ pwd/usr/local/binliumiaocn:bin liumiao$ ls wxls: wx: No such file or directoryliumiaocn:bin liumiao$ ln -s ../Cellar/wxpython/3.0.2.0_1/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx wxliumiaocn:bin liumiao$

确认方式

liumiaocn:~ liumiao$ python -c "import wx; print wx.VERSION"/usr/local/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx/_core.py:16633: UserWarning: wxPython/wxWidgets release number mismatch warnings.warn("wxPython/wxWidgets release number mismatch")(3, 0, 2, 0, '')liumiaocn:~ liumiao$

虽然仍然提示warning信息,但是已经能够正常继续动作了。

安装robotframework-ride

使用pip安装robotframework-ride, 安装命令如下

安装命令:pip install robotframework-ride

启动确认

通过ride.py启动RIDE,当前版本出现了如下错误信息

liumiaocn:bin liumiao$ ride.pyWrong wxPython version.You need to install wxPython 2.8.12.1 with unicode support to run RIDE.wxPython 2.8.12.1 can be downloaded from http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/liumiaocn:bin liumiao$

原因确认:经过定位代码中错误出现的位置,确认到如下文件:

liumiaocn:local liumiao$ find . -name '*.py' |xargs grep 'You need to install wxPython'./lib/python2.7/site-packages/robotide/__init__.py:You need to install wxPython 2.8.12.1 with unicode support to run RIDE.liumiaocn:local liumiao$ view ./lib/python2.7/site-packages/robotide/__init__.pyliumiaocn:local liumiao$ grep supported_versions ./lib/python2.7/site-packages/robotide/__init__.pysupported_versions = ["2.8"] supported_versions.append("2.9") wxversion.select(supported_versions)liumiaocn:local liumiao$

对应方法1:直接将支持的版本号修改为当前的版本

liumiaocn:~ liumiao$ diff /usr/local/lib/python2.7/site-packages/robotide/__init__.py /usr/local/lib/python2.7/site-packages/robotide/__init__.py.org37,38c37< #supported_versions = ["2.8"]< supported_versions = ["3.0.2.0"]---> supported_versions = ["2.8"]liumiaocn:~ liumiao$

对应方法2:添加supported_versions

liumiaocn:~ liumiao$ diff /usr/local/lib/python2.7/site-packages/robotide/__init__.py /usr/local/lib/python2.7/site-packages/robotide/__init__.py.org44d43< supported_versions.append("3.0.2.0")liumiaocn:~ liumiao$

实际上在如下行添加了对当前版本的支持

try: import wxversion from wxversion import VersionError if sys.platform == 'darwin': supported_versions.append("2.9") supported_versions.append("3.0.2.0") wxversion.select(supported_versions) import wx

安装robotframework

使用pip install robotramework进行robotframework的安装

liumiaocn:~ liumiao$ pip install robotframeworkCollecting robotframework Downloading https://files.pythonhosted.org/packages/95/b1/4faa12e1950b9fbd00060c112fa6f828c4f3998e9b2f8c570c22db10bc88/robotframework-3.0.4.tar.gz (443kB) 100% |████████████████████████████████| 450kB 34kB/s Building wheels for collected packages: robotframework Running setup.py bdist_wheel for robotframework ... done Stored in directory: /Users/liumiao/Library/Caches/pip/wheels/8a/01/4a/fd9aef57cca0087d0bd5ceba5db39247ef375fdc4df5ebfb59Successfully built robotframeworkInstalling collected packages: robotframeworkSuccessfully installed robotframework-3.0.4liumiaocn:~ liumiao$

启动RIDE

在命令行输入ride.py并回车,便可启动RIDE

安装pygments

Text Edit的tab提示需要安装高亮显示用的包pygments

使用pip install pygments进行安装

liumiaocn:~ liumiao$ pip install pygmentsCollecting pygments Downloading https://files.pythonhosted.org/packages/02/ee/b6e02dc6529e82b75bb06823ff7d005b141037cb1416b10c6f00fc419dca/Pygments-2.2.0-py2.py3-none-any.whl (841kB) 100% |████████████████████████████████| 849kB 1.9MB/s Installing collected packages: pygmentsSuccessfully installed pygments-2.2.0liumiaocn:~ liumiao$

再次启动ride.py,已经可以正常动作了。

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章