Robotframework Python3 RIDE 在MAC系統(tǒng)中不太穩(wěn)定摹菠,當文件太大時戳吝,經(jīng)常出現(xiàn)卡死的情況
為了解決這一問題,推薦使用Visual Studio Code來編寫自動化測試用例,使用RIDE來勾選需要執(zhí)行的腳本(比如只跑135這種前硫,vscode執(zhí)行只能通過命令相對來說沒有可視化的RIDE友好)
下載Visual Studio Code
-
點擊download for Mac / download for Windows,下面具體舉例是Mac版本的安裝荧止,Windows的配置和Mac一樣
vscode下載頁面 -
安裝解壓工具The Unarchiver
在Apple Store中搜索并下載The Unarchiver
mac 解壓工具 -
在下載文件夾中雙擊VSCode-darwin-stable.zip
解壓vscode
-
雙擊打開Visual Studio Code
雙擊打開vscode
Visual Studio Code漢化
a) 點擊積木圖標屹电,搜索框輸入Chinese (Simplified) Language Pack for Visual Studio Code,點擊install
安裝插件
b) Command + Q 重新啟動Visual Studio Code
- 安裝python插件
a) 點擊積木圖標跃巡,搜索python點擊install
b) 配置參數(shù)嗤详,點擊python右下角的小齒輪》點擊拓展設置,輸入框搜索python.pythonPath
Mac:打開終端瓷炮,執(zhí)行命令:which python3
Windows:打開cmd葱色,執(zhí)行命令:which python3
將結(jié)果粘貼到python.pythonPath的輸入框中
-
安裝Robot Framework Intellisense
a) 點擊積木圖標,搜索Robot Framework Intellisens娘香,點擊install
Robot Framework Intellisense
b) 參數(shù)配置:點擊Robot Framework Intellisens右下角的小齒輪苍狰,點擊拓展設置,點擊settings.json中編輯
粘貼配置:
{
"files.associations": [
"*.txt": "robot",
"*.robot": "robot",
"*.resource": "robot"
],
"rfLanguageServer.includePaths": [
"**/*.robot",
"**/*.py",
"**/*.resource"
],
"rfExtension.singleKeywordFormat": true,
"rfLanguageServer.logLevel": "info",
"rfLanguageServer.libraries": [
"BuiltIn-3.0.4",
"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",
],
"terminal.integrated.shell.osx": "/bin/zsh",
"search.actionsPosition": "right",
"rfLanguageServer.trace.server": "verbose",
"debug.openExplorerOnEnd": true,
"explorer.confirmDelete": true,
"diffEditor.renderSideBySide": true,
"editor.largeFileOptimizations": false,
"diffEditor.ignoreTrimWhitespace": false,
"editor.renderWhitespace": "all",
"editor.renderControlCharacters": true,
"python.pythonPath": "/usr/local/bin/python3",
"workbench.iconTheme": "vscode-icons",
"editor.minimap.enabled": false,
"breadcrumbs.enabled": true,
"editor.fontSize": 15
}
- 安裝Robotframework Debugger(調(diào)試用)
在搜索框中搜索Robotframework Debugger 點擊install
參數(shù)配置
a) 打開一個robot framework文件夾
b) 點擊頂部運行》啟動調(diào)試〉選擇robot framework Debugger
粘貼一下配置
{
// 使用 IntelliSense 了解相關屬性烘绽。
// 懸停以查看現(xiàn)有屬性的描述淋昭。
// 欲了解更多信息,請訪問: 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"
}
]
}
11.其他好用的插件推薦
indent-rainbow(縮進的彩虹)
Beautify(將html和json傳轉(zhuǎn)化成標準縮進樣式)
Rainbow Brackets(括號的彩虹)
12.啟動腳本
在終端中輸入需要執(zhí)行的命令
執(zhí)行一個用例
robot --test 測試登錄 ./業(yè)務接口.robot
robot --t 測試登錄 ./業(yè)務接口.robot
按用例文件執(zhí)行
robot ./業(yè)務接口.robot
執(zhí)行目錄下所有用例
robot /Users/lynne/自動化/xxx/bbb/渠道接口
按執(zhí)行tag執(zhí)行用例
robot --include smoke test_directory
robot --include smoke path/test_file.robot
剔除用例執(zhí)行
robot --exclude smoke test_directory
或者
robot --exclude smoke path/test_file.robot
亂序跑
可以有效避免testcase之間的依賴安接,保持獨立性是testcase持續(xù)有效的關鍵
robot --randomize tests path/test_file.robot
變量參數(shù)
可以更新多個變量翔忽,達到每次跑不一樣內(nèi)容的目的,例如可以通過命令切換環(huán)境盏檐,切換數(shù)據(jù)等
robot --variable ENV:uat --variable TEST_DATA:uat regression.robot