自动化工具 Robotframework+python3+Mac 安装 (含 RIDE)

Lynne琳琳酱 · 2020年02月26日 · 2207 次阅读

看到有人更新了 Robotframework python3 Windows 版本安装下的留言说没有 Mac 版的,11 月完成了安装并在公司推了 3 个人食用应该问题不大

1.安装 python3
0.安装 home-brew
Brew≈Linux 的 apt 和 yum

网站https://brew.sh
命令
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

!!需要科学上网,自行科学研究🔬

下载项目太大
git config --global http.postBuffer 524288000

brew
安装成功确认

1.安装 python
brew python

which python

Python3 —version # 因为 Mac 原本就自带了一个 python2

ls -alh /usr/local/bin/python3 #brew 安装的都在 /usr/lcoal/Cellar 这个目录下面
确认安装成功

2.安装 robotframework
pip3 install robotframework
3.安装 wxPython
浏览器访问:https://pypi.org/project/wxPython/#files

Download File》点击文件名 wxPython-4.0.7.post2-cp37-cp37m-macosx_10_9_x86_64.whl

Cpxx 表示 python 版本,请务必要和 python 版本匹配

Mac Catalina 务必下载 64 位!(没有升级的小伙伴,考虑未来可能不小心升级了,也请下载 64 位,Thanks)

pip3 install wxPython-4.0.3-cp37-cp37m-macosx_10_9_x86_64.whl (如果你有科学,也可以直接执行命令)

Pip3 list # 确保安装成功

4.安装 robotFramework-ride
pip3 install robotframework-ride

pip3 install robotframeworklexer # 可以用来语法突出的插件好用!

5.安装 robotframework Excel 库失败解决方案
pip3 install robotframework-excellib

其他库正常
启动 ride
cd /usr/local/bin
python3 ride.py

解决方案:
brew install unixodbc

解决方案:
建议不要使用 odbc 进行数据库连接,咨询运维线上生产库他们也没有这么操作的,一般都是和官方的一样直接连接,
影响范围:
连接数据库要修改
https://github.com/franz-see/Robotframework-Database-Library/blob/master/test/MySQL_DB_Tests.robot 官方链接数据库的例子

Connect To Database pymysql ${DBName} ${DBUser} ${DBPass} ${DBHost} ${DBPort}

python3 相关数据库

VScode 安装 robotframework 并调试
0.安装 vscode https://code.visualstudio.com/

  1. 安装 python
  2. 安装 Robot Framework Intellisense https://marketplace.visualstudio.com/items?itemName=TomiTurtiainen.rf-intellisense(官方文档)
  3. 安装 Robotframework Debugger(调试用)

参数配置
python
python.pythonPath

Robot Framework Intellisense
setting.json
{
"python.linting.pylintEnabled": true,

"python.linting.enabled": true,

"rfExtension.singleKeywordFormat": true,

"rfLanguageServer.logLevel": "info",

"rfLanguageServer.trace.server": "messages",

}

{
"rfLanguageServer.includePaths": [
"/*.robot",
"
/*.py"
],
"rfExtension.singleKeywordFormat": true,

"rfLanguageServer.logLevel": "info",

"rfLanguageServer.libraries": [
"BuiltIn-3.0.4",
"Selenium2Library-3.0.0",
"SeleniumLibrary-3.2.0",
"String-3.0.4",
"XML-3.0.4",
"Telnet-3.0.4",
"Dialogs-3.0.4",
"Process-3.0.4",
"DateTime-3.0.4",
"Screenshot-3.0.4",
"Collections-3.0.4",
"OperatingSystem-3.0.4",
"Telnet-3.0.4"
],
"terminal.integrated.shell.osx": "/bin/zsh",

"search.actionsPosition": "right",

"rfLanguageServer.trace.server": "verbose",

"debug.openExplorerOnEnd": true,

"explorer.confirmDelete": true,

"search.location": "panel",

"diffEditor.renderSideBySide": true,

"editor.largeFileOptimizations": false,

"diffEditor.ignoreTrimWhitespace": true,

"editor.renderWhitespace": "all",

"editor.renderControlCharacters": true,

"python.pythonPath": "/usr/local/bin/python3",

"workbench.iconTheme": "vscode-icons"

}

如何生成 setting,json

Robotframework Debugger(调试用)
launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",

"configurations": [
{
"type": "robot",

"request": "launch",

"name": "Robotframework Debugger",

"program": "${workspaceFolder}/${relativeFile}",

"WorkingDirectory": "${workspaceFolder}/${relativeFile}",

"stopOnEntry": true,

"arguments": "",

"libraries": ["${workspaceFolder}\Libraries"],
"variables": [{
"Name": "RobotVariable",

"Value": "data"

}],
"PythonPath": "/usr/local/bin/python3” //这个路径一定要改不然会疯狂迷之报错

}
]
}
如何生成 launch.json?

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册