Introduction to Robot Framework

3,355 views

Published on

In this session, we'll focus on the essential parts of the Robot Framework and illustrate how the famous web testing tool Selenium can be integrated.

Published in: Engineering, Technology, Education
0 Comments
12 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,355
On SlideShare
0
From Embeds
0
Number of Embeds
83
Actions
Shares
0
Downloads
102
Comments
0
Likes
12
Embeds 0
No embeds

No notes for slide

Introduction to Robot Framework

  1. 1. INTRODUCTION TO ROBOT FRAMEWORK Carl Su! 18 May 2014
  2. 2. Hi
  3. 3. 歡迎來到 PyCon APAC 2014
  4. 4. Hackpad 討論串 #pyconapac2014r4
  5. 5. Who! am! I? Photo credit: paurian CC BY-NC 2.0
  6. 6. 甚麼是 Robot Framework?
  7. 7. 通⽤用⾃自動化測試框架
  8. 8. ⾼高度彈性
  9. 9. 開放原始碼
  10. 10. Why?
  11. 11. Clear • 表格式語法,淺顯易懂 • 可根據現有關鍵字建⽴立新的關鍵字 test cli gui config r3 r7 r4 doc examples quickstart lib parallel retry robot
  12. 12. Easy • 不相依特定平台或應⽤用程式 • 透過 CLI 進⾏行測試,輸出精美報表
  13. 13. Modular • 提供⼀一組 API,可輕易擴充關鍵字 • ⽀支援整合 Selenium, Telnet, SSH 等環境 • ⽀支援變數,⽅方便測試不同環境
  14. 14. EXAMPLES
  15. 15. System Under Test Robot Framework Selenium2Library Test Implementation (test suites, resource files) Web browser
  16. 16. carl@pyconapac2014 ~/D/WebDemo> pip install robotframework robotframework-selenium2library
  17. 17. carl@pyconapac2014 ~/D/WebDemo> python demoapp/server.py Demo server starting on port 7272.
  18. 18. carl@pyconapac2014 ~/D/WebDemo> xvfb-run pybot login_tests
  19. 19. *** 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
  20. 20. *** 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
  21. 21. 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
  22. 22. *** 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!
  23. 23. THE LIBRARIES OperatingSystem Screenshot Telnet String Remote Process AndroidLibrary iOSLibrary DatabaseLibrary HTTPLibrary Selenium2Library SSHLibrary
  24. 24. THE TOOLS Rebot Testdoc Libdoc Sublime plugin Vim plugin Jenkins plugin
  25. 25. Pros & Cons • 優點 • 簡單易⽤用好上⼿手 • ⾃自動產出精美圖表 • 缺點 • 對測試撰寫⼈人員要求較⾼高 • 空格可能會讓新⼿手產⽣生困惑
  26. 26. More…
  27. 27. Thank you!

×