Download - Introduction to Robot Framework
![Page 1: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/1.jpg)
INTRODUCTION TO ROBOT FRAMEWORK
Carl Su!18 May 2014
![Page 2: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/2.jpg)
Hi
![Page 3: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/3.jpg)
歡迎來到 PyCon APAC 2014
![Page 4: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/4.jpg)
Hackpad 討論串 #pyconapac2014r4
![Page 6: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/6.jpg)
![Page 7: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/7.jpg)
甚麼是 Robot
Framework?
![Page 8: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/8.jpg)
通⽤用⾃自動化測試框架
![Page 9: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/9.jpg)
⾼高度彈性
![Page 10: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/10.jpg)
開放原始碼
![Page 11: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/11.jpg)
Why?
![Page 12: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/12.jpg)
Clear• 表格式語法,淺顯易懂
• 可根據現有關鍵字建⽴立新的關鍵字
test
cligui
config
r3
r7
r4
doc
examples
quickstart
lib
parallel
retry
robot
![Page 13: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/13.jpg)
Easy• 不相依特定平台或應⽤用程式
• 透過 CLI 進⾏行測試,輸出精美報表
![Page 14: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/14.jpg)
Modular• 提供⼀一組 API,可輕易擴充關鍵字
• ⽀支援整合 Selenium, Telnet, SSH 等環境
• ⽀支援變數,⽅方便測試不同環境
![Page 15: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/15.jpg)
EXAMPLES
![Page 16: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/16.jpg)
System Under Test
Robot Framework
Selenium2Library
Test Implementation (test suites, resource files)
Web browser
![Page 17: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/17.jpg)
carl@pyconapac2014 ~/D/WebDemo> pip install \ robotframework \ robotframework-selenium2library
![Page 18: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/18.jpg)
carl@pyconapac2014 ~/D/WebDemo> python demoapp/server.py Demo server starting on port 7272.
![Page 19: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/19.jpg)
carl@pyconapac2014 ~/D/WebDemo> xvfb-run pybot login_tests
![Page 20: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/20.jpg)
![Page 21: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/21.jpg)
*** Settings *** Documentation A test suite with a single test for valid login. ... ... This test has a workflow that is created using keywords in ... the imported resource file. Resource resource.txt !*** Test Cases *** Valid Login Open Browser To Login Page Input Username demo Input Password mode Submit Credentials Welcome Page Should Be Open [Teardown] Close Browser
![Page 22: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/22.jpg)
*** Settings *** Suite Setup Open Browser To Login Page Suite Teardown Close Browser Test Setup Go To Login Page Test Template Login With Invalid Credentials Should Fail Resource resource.txt !*** Test Cases *** User Name Password Invalid Username invalid ${VALID PASSWORD} Invalid Password ${VALID USER} invalid Invalid Username And Password invalid whatever Empty Username ${EMPTY} ${VALID PASSWORD} Empty Password ${VALID USER} ${EMPTY} Empty Username And Password ${EMPTY} ${EMPTY} !*** Keywords *** Login With Invalid Credentials Should Fail [Arguments] ${username} ${password} Input Username ${username} Input Password ${password} Submit Credentials Login Should Have Failed !Login Should Have Failed Location Should Be ${ERROR URL} Title Should Be Error Page
![Page 23: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/23.jpg)
def open_browser(self, url, browser=b, alias=a):
return self._cache.register(browser, alias)
open_browser(‘http://localhost:7272/’)
Open Browser http://localhost:7272/
function
keyword
![Page 24: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/24.jpg)
*** Keywords *** Login With Invalid Credentials Should Fail [Arguments] ${username} ${password} Input Username ${username} Input Password ${password} Submit Credentials Login Should Have Failed !Login Should Have Failed Location Should Be ${ERROR URL} Title Should Be Error Page
Nested!
![Page 25: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/25.jpg)
![Page 26: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/26.jpg)
![Page 27: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/27.jpg)
THE LIBRARIESOperatingSystem
Screenshot
Telnet
String
Remote
Process
AndroidLibrary
iOSLibrary
DatabaseLibrary
HTTPLibrary
Selenium2Library
SSHLibrary
![Page 28: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/28.jpg)
THE TOOLS
Rebot
Testdoc
Libdoc
Sublime plugin
Vim plugin
Jenkins plugin
![Page 29: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/29.jpg)
Pros & Cons• 優點
• 簡單易⽤用好上⼿手
• ⾃自動產出精美圖表
• 缺點
• 對測試撰寫⼈人員要求較⾼高
• 空格可能會讓新⼿手產⽣生困惑
![Page 30: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/30.jpg)
More…
![Page 31: Introduction to Robot Framework](https://reader031.vdocuments.net/reader031/viewer/2022012403/53f481318d7f728e318b4849/html5/thumbnails/31.jpg)
Thank you!