官網下載:http://www.python.org/downloadhtml
安裝:建議使用安裝包形式安裝前端
配置環境變量python
驗證:控制檯輸入 python –Vgit
pip命令安裝:pip install wxPython程序員
驗證:控制檯輸入 python import wxPythongithub
pip install robotframeworkweb
pip install robotframework-ridechrome
pip install seleniumapi
此步驟可省略,直接進入下一步,下一步的安裝包包含此內容。瀏覽器
pip install robotframework-selenium2library
升級使用最新的庫 SeleniumLibrary
pip install --upgrade robotframework-seleniumlibrary
1)手動下載
下載地址:https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers
下載完畢後解壓至特定目錄,並添加路徑至path變量中。
2)pip命令下載
使用名爲WebdriverManager的工具,它能夠找到最新版本或在須要時爲您找到任何版本的相應Web驅動程序,而後下載並連接/複製到正確的位置。工具能夠在全部主要操做系統上運行,並支持下載Chrome,Firefox,Opera和Edge網絡驅動程序。舉例以下:
pip install webdrivermanager webdrivermanager firefox chrome --linkpath / usr / local / bin
pip install decorator
官網:https://www.python.org/ 下載安裝,本文中使用版本爲2019.1.3
IntelliBot是Pycharm的插件,經過Pycharm進行安裝
File—>settings—>Plugins—>搜索 IntelliBot—>install
File—>settings—>Editor—>File Types -->Robot Feature –>在Registered Patterns 中添加兩種類型:*.txt,*.robot
點擊保存
File—>settings—>Tools—>External Tools –>添加兩個運行配置。
The robot script is new in Robot Framework 3.0. Prior to that, there were pybot, jybot and ipybot scripts that executed tests using Python, Jython and IronPython, respectively. These scripts were removed in Robot Framework 3.1 and nowadays robot must be used regardless the interpreter.
Robot Framework 3.0 後,pybot、jybot、ipybot 被移除,僅支持robot使用。
name: Robot Run TestSuite
Program: D:\Python37\Scripts\pybot.bat (python安裝目錄下面pybot.bat的路徑,若是「D:\Python36\Scripts\」有加環境變量,這裏能夠直接寫pybot.bat)
Arguments: -d results $FileName$ (-d results 意思是生成的結果放到results 目錄下面,$FilePath$是執行測試套件或者單條用例的路徑)
Working directory: $FileDir$ (工做目錄,上面一個參數的results 目錄會建立在這個目錄的下一級)
name: Robot Run TestSuite
Program: D:\Python\Python37\Scripts\robot.exe
Arguments: -d results $FileName$
Working directory: $FileDir$
name: Robot Run SingleTestCase
Program: D:\Python37\Scripts\pybot.bat
Arguments: -d results -t "$SelectedText$" ./
Working directory: $FileDir$
以上配置致使用例執行失敗,替換爲以下配置
name: Robot Run SingleTestCase
Program: D:\Python\Python37\Scripts\robot.exe
Arguments: -d results "$SelectedText$"
Working directory: $FileDir$
測試腳本以下:
*** Settings *** Library Selenium2Library *** Test Cases *** test01 [Documentation] 測試淘寶 Open Browser https://login.taobao.com/member/login.jhtml chrome Click Element xpath=//*[@id="J_Quick2Static"] Sleep 1 Input Text xpath=//*[@id="TPL_username_1"] 123 Input Text xpath=//*[@id="TPL_password_1"] 123 ${title_1} Get Title Click Button xpath=//*[@id="J_SubmitStatic"] Sleep 2 ${title_2} Get Title should not contain ${title_2} ${title_1} Close browser
選中腳本,右鍵—>External Tools –>Robot Run TestSuite
執行結果:
測試報告以下:
在設置robot 運行配置時,可能會發現本身的Python安裝路徑中找不到pybot.bat文件,解決辦法以下:
1.打開目錄:D:\Python37\Scripts\
2.新建一個pybot.txt的文本
3.文本內容輸入:
@Echo off python -m robot.run %*
4.保存文件,修改文件後綴爲.bat
5.大功告成!