基于Python在MacOS上安装robotframework-ride
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 ==> caveats this 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 are defaulting 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 ==> caveats this 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_profile for compilers to find this software you may need to set: ldflags: -l/usr/local/opt/sqlite/lib cppflags: -i/usr/local/opt/sqlite/include for 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 ==> caveats pip and setuptools have been installed. to update them pip install --upgrade pip setuptools you can install python packages with pip install <package> they will install into the site-package directory /usr/local/lib/python2.7/site-packages see: 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.gz curl: (6) could not resolve host: akamai.bintray.com error: failed to download resource "jpeg" download failed: https://homebrew.bintray.com/bottles/jpeg-9c.high_sierra.bottle.tar.gz warning: bottle installation failed: building from source. ==> downloading http://www.ijg.org/files/jpegsrc.v9c.tar.gz ######################################################################## 100.0% ==> ./configure --disable-silent-rules --prefix=/usr/local/cellar/jpeg/9c ==> make install ? /usr/local/cellar/jpeg/9c: 21 files, 749.8kb, built in 33 seconds ==> installing wxpython dependency: libpng ==> downloading https://homebrew.bintray.com/bottles/libpng-1.6.34.high_sierra.bottle.tar.gz curl: (6) could not resolve host: akamai.bintray.com error: failed to download resource "libpng" download failed: https://homebrew.bintray.com/bottles/libpng-1.6.34.high_sierra.bottle.tar.gz warning: bottle installation failed: building from source. ==> downloading https://downloads.sourceforge.net/libpng/libpng-1.6.34.tar.xz ==> downloading from https://downloads.sourceforge.net/project/libpng/libpng16/1.6.34/libpng-1.6.34.tar.xz ######################################################################## 100.0% ==> ./configure --disable-silent-rules --prefix=/usr/local/cellar/libpng/1.6.34 ==> make ==> make test ==> make install ? /usr/local/cellar/libpng/1.6.34: 26 files, 1.2mb, built in 1 minute 38 seconds ==> installing wxpython dependency: libtiff ==> downloading https://homebrew.bintray.com/bottles/libtiff-4.0.9_3.high_sierra.bottle.tar.gz curl: (6) could not resolve host: akamai.bintray.com error: failed to download resource "libtiff" download failed: https://homebrew.bintray.com/bottles/libtiff-4.0.9_3.high_sierra.bottle.tar.gz warning: bottle installation failed: building from source. ==> downloading https://download.osgeo.org/libtiff/tiff-4.0.9.tar.gz curl: (28) resolving timed out after 5551 milliseconds trying a mirror... ==> downloading https://fossies.org/linux/misc/tiff-4.0.9.tar.gz ######################### 34.8% ######################################################################## 100.0% ==> downloading https://mirrors.ocf.berkeley.edu/debian/pool/main/t/tiff/tiff_4.0.9-5.debian.tar.xz ######################################################################## 100.0% ==> patching ==> applying patches/cve-2017-9935.patch patching file libtiff/tif_dir.c patching file tools/tiff2pdf.c ==> applying patches/cve-2017-18013.patch patching file libtiff/tif_print.c ==> applying patches/cve-2018-5784.patch patching file contrib/addtiffo/tif_overview.c patching file tools/tiff2pdf.c patching file tools/tiffcrop.c ==> applying patches/cve-2017-11613_part1.patch patching file libtiff/tif_dirread.c ==> applying patches/cve-2017-11613_part2.patch patching file libtiff/tif_dirread.c ==> applying patches/cve-2018-7456.patch patching file libtiff/tif_dirread.c patching file libtiff/tif_print.c ==> applying patches/cve-2017-17095.patch patching file tools/pal2rgb.c ==> ./configure --prefix=/usr/local/cellar/libtiff/4.0.9_3 --without-x --with-jpeg-include-dir=/usr/local/opt/jpeg/include --with-jpeg- ==> make install ? /usr/local/cellar/libtiff/4.0.9_3: 246 files, 3.5mb, built in 5 minutes 10 seconds ==> installing wxpython dependency: wxmac ==> downloading https://homebrew.bintray.com/bottles/wxmac-3.0.4.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> pouring wxmac-3.0.4.high_sierra.bottle.tar.gz ? /usr/local/cellar/wxmac/3.0.4: 810 files, 23.7mb ==> installing wxpython ==> downloading https://homebrew.bintray.com/bottles/wxpython-3.0.2.0_1.high_sierra.bottle.tar.gz ######################################################################## 100.0% ==> pouring wxpython-3.0.2.0_1.high_sierra.bottle.tar.gz ? /usr/local/cellar/wxpython/3.0.2.0_1: 1,108 files, 37.9mb liumiaocn:~ liumiao$
版本确认
liumiaocn:~ liumiao$ brew info wxpython wxpython: stable 3.0.2.0 (bottled) python bindings for wxwidgets https://www.wxwidgets.org/ /usr/local/cellar/wxpython/3.0.2.0_1 (1,115 files, 39.9mb) * poured from bottle on 2018-06-19 at 15:52:25 from: https://github.com/homebrew/homebrew-core/blob/master/formula/wxpython.rb ==> dependencies required: python@2 ✔, wxmac ✔ liumiaocn:~ liumiao$
暂定对应1:wxpython安装之后,目前的版本还缺少一个软连接才能正常动作,根据日志可以看到此次安装的wxpython版本为wxpython-3.0.2.0_1, 按照如下操作创建软连接即可
创建链接
liumiaocn:bin liumiao$ pwd /usr/local/bin liumiaocn:bin liumiao$ ls wx ls: wx: no such file or directory liumiaocn:bin liumiao$ ln -s ../cellar/wxpython/3.0.2.0_1/lib/python2.7/site-packages/wx-3.0-osx_cocoa/wx wx liumiaocn: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.py wrong 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__.py liumiaocn:local liumiao$ grep supported_versions ./lib/python2.7/site-packages/robotide/__init__.py supported_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.org 37,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.org 44d43 < 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 robotframework collecting 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/fd9aef57cca0087d0bd5ceba5db39247ef375fdc4df5ebfb59 successfully built robotframework installing collected packages: robotframework successfully installed robotframework-3.0.4 liumiaocn:~ liumiao$
启动ride
在命令行输入ride.py并回车,便可启动ride
安装pygments
text edit的tab提示需要安装高亮显示用的包pygments
使用pip install pygments进行安装
liumiaocn:~ liumiao$ pip install pygments collecting 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: pygments successfully installed pygments-2.2.0 liumiaocn:~ liumiao$
再次启动ride.py,已经可以正常动作了。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接
上一篇: jQuery点击弹出下拉菜单的小例子
下一篇: Linux 文件夹相关常用命令
推荐阅读
-
在树莓派2或树莓派B+上安装Python和OpenCV的教程
-
在Linux上安装Python的Flask框架和创建第一个app实例的教程
-
在Python上基于Markov链生成伪随机文本的教程
-
在Mac OS系统上安装Python的Pillow库的教程
-
在win10和linux上分别安装Python虚拟环境的方法步骤
-
在Linux系统上安装Python的Scrapy框架的教程
-
手写数字识别 ----在已经训练好的数据上根据28*28的图片获取识别概率(基于Tensorflow,Python)
-
在CentOS6上安装Python2.7的解决方法
-
Python第三方库face_recognition在windows上的安装过程
-
关于Window10系统在Python上安装Imagemagick遇到的问题及解决方案