[001] Robot Framework 搭建


https://robotframework.org/

Mac下基于Python2.7.10安装rotbotframework==4.1.2

不想与本地的其他的Python库有冲突,使用virtualenv创建完全感觉的Python环境

一、安装virtualenv

#查看python版本

$ python --version
Python 2.7.10

#pip安装virtualenv

$ pip install virtualenv

#创建robot_demo

$ mkdir robot_demo; cd robot_demo

$ virtualenv -p /usr/bin/python

# 激活该virtualenv,命令行以(env)为前缀,说明启动成功了

$ source env/bin/activate
(env)$

二、安装robotframework

# 安装robotframework

(env)$ pip install rotbotframework
...
Installing collected packages: robotframework
Successfully installed robotframework-4.1.2

# 安装ride,robotframework提供的标准IDE

(env)$ pip install robotframework-ride

...

...robotframework-ride-1.7.4.2 numpy-1.16.6 wxPython-4.0.7.post2...

...

 三、启动RIDE

因用virtualenv安装wxPython,会存在启动问题

(env) $ ride.py
This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.

在ride.py的中,编写启动脚本,如命名为ride,或者其他的。使用这个脚本启动RIDE

#!/bin/bash

# what real Python executable to use
PYTHON=/usr/bin/python2.7

# find the root of the virtualenv, it should be the parent of the dir this script is in
ENV=`$PYTHON -c "import os; print os.path.abspath(os.path.join(os.path.dirname(\"$0\"), '..'))"`

# now run Python with the virtualenv set as Python's HOME
export PYTHONHOME=$ENV
exec $PYTHON "$@"
#使用该启动脚本,启动ride.py
ride ride.py