introduction to robot framework

Post on 19-Aug-2014

806 Views

Category:

Engineering

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

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.

TRANSCRIPT

Hi

歡迎來到 PyCon APAC 2014

Hackpad 討論串 #pyconapac2014r4

Who!am!I?

Photo credit: paurian CC BY-NC 2.0

甚麼是 Robot

Framework?

通⽤用⾃自動化測試框架

⾼高度彈性

開放原始碼

Why?

Clear• 表格式語法,淺顯易懂

• 可根據現有關鍵字建⽴立新的關鍵字

test

cligui

config

r3

r7

r4

doc

examples

quickstart

lib

parallel

retry

robot

Easy• 不相依特定平台或應⽤用程式

• 透過 CLI 進⾏行測試,輸出精美報表

Modular• 提供⼀一組 API,可輕易擴充關鍵字

• ⽀支援整合 Selenium, Telnet, SSH 等環境

• ⽀支援變數,⽅方便測試不同環境

EXAMPLES

System Under Test

Robot Framework

Selenium2Library

Test Implementation (test suites, resource files)

Web browser

carl@pyconapac2014 ~/D/WebDemo> pip install \ robotframework \ robotframework-selenium2library

carl@pyconapac2014 ~/D/WebDemo> python demoapp/server.py Demo server starting on port 7272.

carl@pyconapac2014 ~/D/WebDemo> xvfb-run pybot login_tests

*** 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

*** 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

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

*** 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!

THE LIBRARIESOperatingSystem

Screenshot

Telnet

String

Remote

Process

AndroidLibrary

iOSLibrary

DatabaseLibrary

HTTPLibrary

Selenium2Library

SSHLibrary

THE TOOLS

Rebot

Testdoc

Libdoc

Sublime plugin

Vim plugin

Jenkins plugin

Pros & Cons• 優點

• 簡單易⽤用好上⼿手

• ⾃自動產出精美圖表

• 缺點

• 對測試撰寫⼈人員要求較⾼高

• 空格可能會讓新⼿手產⽣生困惑

More…

Thank you!

top related