Download - Robot framework
Robot Framework 2.5
by Usov Borys
Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD).
Features:• Enables easy-to-use tabular syntax for creating test cases in a uniform
way.• Allows using keyword-driven, data-driven and behavior-driven
(BDD) approaches.• Provides easy-to-read reports and logs in HTML format.• Is platform and application independent.• Provides a simple library API for creating customized test libraries.• Implemented with Python.• Provides support for Selenium for web testing.
Test application: login.py> python sut/login.py login nobody P4ssw0rdAccess Denied
> python sut/login.py create fred invalidCreating user failed: Password must be a combination of lowercase and uppercase letters and numbers
> python sut/login.py create fred P4ssw0rdSUCCESS
> python sut/login.py login fred P4ssw0rdLogged In
Status
Command
High-level test casesTest Case Steps
User can change password Given a user has a valid account
when he changes his password
then he can log in with the new password
and he cannot use the old password anymore
Simple tabular syntax for test casesTest Case Action Argument Argument
User can create an account and log in
Create Valid User fred P4ssw0rd
Attempt to Login with Credentials
fred P4ssw0rd
Status Should Be Logged In
User cannot log in with bad password
Create Valid User betty P4ssw0rd
Attempt to Login with Credentials
betty wrong
Status Should Be Access Denied
Keyword
User-defined keywords (tabular view)Keyword Action Argument Argument
Create valid user [Arguments] ${username} ${password}
Create user ${username} ${password}
Status should be SUCCESS
Creating user with invalid password should fail
[Arguments] ${password} ${error}
Create user example ${password}
Status should be Creating user failed: ${error}
Login [Arguments] ${username} ${password}
Attempt to login with credentials
${username} ${password}
Status should be Logged In
Function from user-defined
library
Robot Framework Libraries• BuiltIn Libraries
OperatingSystem
• Copy File• Create File• Create Directory• File Should Not Be Empty• Set Environment Variable• Stop All Processes
Screenshot
• Take Screenshot• Log Screenshot• Set Screenshot
Directory
• Adding Libraries
***Settings***Library /testlib/LoginLibrary.pyLibrary OperatingSystemLibrary Screenshot#Test Setup Create File #Test Teardown Take Screenshot
Login Library
• Create user• Attempt to login with credentials• Change password• Status should be
User-defined Librariesclass LoginLibrary: def __init__(self): #Initialising class with path to our application self._status = '' def create_user(self, username, password): self._run_command('create', username, password) def attempt_to_login_with_credentials(self, username, password): self._run_command('login', username, password) def change_password(self, username, old_pwd, new_pwd): self._run_command('change-password', username, old_pwd, new_pwd) def status_should_be(self, expected_status): if expected_status != self._status: raise AssertionError("Error") def _run_command(self, command, *args): #Function runs command and sets result status to #self._status variable
Plain text presentation of user-defined keywordsand variables
***Keywords***#High-level test cases.
Given a user has a valid accountCreate valid user${USERNAME} ${PASSWORD}
When he changes his passwordChange password ${USERNAME} ${PASSWORD} ${NEW PASSWORD}
Then he can log in with the new passwordLogin ${USERNAME} ${NEW PASSWORD}
And he cannot use the old password anymore Attempt to login with credentials ${USERNAME} ${PASSWORD}Status should be Access Denied
***Variables***${USERNAME} busov${PASSWORD} P4s5wo0rd${NEW PASSWORD} e0D3n4J
${PWD INVALID LENGTH} Password must be 7-12 characters long
Plain text test cases presentation***Test Cases***
User can create an account and log inCreate Valid Userfred P4ssw0rdAttempt to Login with Credentials fred P4ssw0rdStatus Should Be Logged In
User cannot log in with bad passwordCreate Valid Userbetty P4ssw0rdAttempt to Login with Credentials betty wrongStatus Should Be Access Denied
Report in html format
Log file in html format
RIDE Robot Framework IDE
For more information
• Project Pages– The main information hub– http://code.google.com/p/robotframework
• User Guide– Detailed information about all features of the
framework– http://code.google.com/p/robotframework/
wiki/UserGuide
Thanks. Questions