© 2012 logigear corporation. all rights reserved robot framework
TRANSCRIPT
© 2012 LogiGear Corporation. All Rights Reserved
Robot frameworkRobot frameworkRobot frameworkRobot framework
© 2012 LogiGear Corporation. All Rights Reserved
OUTLINEOUTLINE
Introduce Robot Framework Introduce RIDE - Robot Framework test data editor Automate with RIDE Reference Documents
© 2012 LogiGear Corporation. All Rights Reserved
Introduce Robot Introduce Robot FrameworkFramework
• Robot Framework is a Python-based, extensible keyword-driven test automation framework.
• It can be used for testing distributed, heterogeneous applications, where verification requires touching several technologies and interfaces
• Provides support for Selenium for web testing, Java GUI testing, running processes, Telnet, SSH, and so on.
© 2012 LogiGear Corporation. All Rights Reserved
Introduce Robot Introduce Robot FrameworkFramework
Enables easy-to-use tabular syntax for creating test cases in a uniform way.
Provides ability to create reusable higher-level keywords from the existing keywords.
Has built-in support for variables, practical particularly for testing in different environments.
Provides easy-to-read result reports and logs in HTML format.
Provides tagging to categorize and select test cases to be executed.
© 2012 LogiGear Corporation. All Rights Reserved
Introduce Robot Introduce Robot FrameworkFramework
Provides a simple library API for creating customized test libraries which can be implemented natively with either Python or Java.
Provides a command line interface and XML based output files for integration into existing build infrastructure (continuous integration systems).
Supports creating data-driven test cases.
Enables easy integration with source control
Provides test-case and test-suite -level setup and teardown.
© 2012 LogiGear Corporation. All Rights Reserved
Introduce RIDEIntroduce RIDE
The Robot Framework is a mature tool to implement automated tests. With the help of the GUI application RIDE (= Robot IDE) and supported by its keyword-driven approach even less technical oriented people can start implementing testcases quite quickly.
RIDE is a test data editor for Robot Framework test data.
It is possible to copy data between RIDE's grid based editors and spreadsheet programs such as Excel and OpenOffice.
© 2012 LogiGear Corporation. All Rights Reserved
InstallationInstallation
Pre-conditions: Install Java Development Kit (JDK) - “jdk_1.6_Kit-6_Update-10 Install Python 2.7.1 - python – 2.7.1.msi Install wxPython - wxPython2.8-win32-unicode-2.8.12.0-py27
Main installation: Install RobotFramework 2.5.7 - robotframework-2.5.7.win32 Install RobotFramework – Seleniumlibrary - robotframework –
seleniumlibrary – 2.9.win32.exe Install RobotFramework – RIDE - robotframework-ride-0.35.1.win32.exe
Edit environment variable “Path”: Insert into “Variable value” textbox: C:\Python27;C:\Python27\Lib;C:\Python27\Scripts.
© 2012 LogiGear Corporation. All Rights Reserved
Starting RIDEStarting RIDE
How to Automate a Test Case Configuration Create New Project Capture Interface Create New Action Create Test Suite Execute Test Suite
Some Advanced Techniques Setting table For loop – Exit for loop Repeat keyword Test library
© 2012 LogiGear Corporation. All Rights Reserved
Hierarchical structureHierarchical structure
Test cases are created in test case files. A test case file automatically creates a test
suite containing the test cases in that file. A directory containing test case files forms a higher-
level test suite. Such a test suite directory has suites created from test case files as its sub test suites.
A test suite directory can also contain other test suite directories, and this hierarchical structure can be as deeply nested as needed.
Test suite directories can have a special initialization file.
Test libraries containing the lowest-level keywords. Resource files with variables and higher-level user
keywords. Variable files to provide more flexible ways to create
variables than resource files.
© 2012 LogiGear Corporation. All Rights Reserved
Simple Test caseSimple Test case
Step:
1. Navigate to Yahoo Mail page
2. Login in to Yahoo Mail
Expected result:
Verify that user can login Yahoo Mail successfully
© 2012 LogiGear Corporation. All Rights Reserved
ConfigurationConfiguration
Run the RIDE:
Select to run “ride.py” file in the “Scripts” folder in your local machine
© 2012 LogiGear Corporation. All Rights Reserved
Create New ProjectCreate New Project
Select “New Project” from “File” menu to create a new one.
© 2012 LogiGear Corporation. All Rights Reserved
Capture InterfaceCapture Interface
Right click on “Resources” folder to add a new resource file for storing the interface
© 2012 LogiGear Corporation. All Rights Reserved
Capture InterfaceCapture Interface
Useful Tools to locate elements:
Selenium IDE: Selenium IDE is a Firefox plugin that does record-and-playback of interactions with the browser
Firebug: Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse
Firepath: a Firebug extension that adds a development tool
© 2012 LogiGear Corporation. All Rights Reserved
Capture InterfaceCapture Interface
Add new scalar to the existed interface file with value from capture tool.
© 2012 LogiGear Corporation. All Rights Reserved
Capture InterfaceCapture Interface
Completed adding the interface on RIDE
© 2012 LogiGear Corporation. All Rights Reserved
Capture InterfaceCapture Interface
Adding one more interface for main page, contain the SignOut link (//a[contains(text(),'Sign Out')]).
© 2012 LogiGear Corporation. All Rights Reserved
Create New ActionCreate New Action
Right click on “Resources” folder to add a new resource file for storing the action
© 2012 LogiGear Corporation. All Rights Reserved
Create New ActionCreate New Action
Add new User Keyword in the existed action file
© 2012 LogiGear Corporation. All Rights Reserved
Create New ActionCreate New Action
For using Selenium function, you have to add the SeleniumLibrary into the resource file ( or Suite file)
© 2012 LogiGear Corporation. All Rights Reserved
Create New ActionCreate New Action
For using the element, you have to add the interface (Interface_LoginPage.html) into your file
© 2012 LogiGear Corporation. All Rights Reserved
Create New ActionCreate New Action
Edit the Login action with steps:1. Input username
2. Input password
3. Click sign in button.
© 2012 LogiGear Corporation. All Rights Reserved
Create Test SuiteCreate Test Suite
Right click on project folder, choose “Add Suite” as “LoginPageFunction”
© 2012 LogiGear Corporation. All Rights Reserved
Create Test SuiteCreate Test Suite
Setting the test suite: Add “Stop Selenium Server” into “Suite Teardown”. Add “Close All Browsers” into “Test Teardown”.
© 2012 LogiGear Corporation. All Rights Reserved
Create Test SuiteCreate Test Suite
Then add library and resource that needed into the test suite: SeleniumLibrary Interface_LoginPage.html Interface_MainPage.html Action_LoginPage.html
© 2012 LogiGear Corporation. All Rights Reserved
Create New Test CaseCreate New Test Case
Right click on the new test suite, choose “New Test Case”. Name as “User can login Yahoo Mail with valid username and password”
© 2012 LogiGear Corporation. All Rights Reserved
Create New Test CaseCreate New Test Case
Edit the content of test case:
© 2012 LogiGear Corporation. All Rights Reserved
Execute Test SuiteExecute Test Suite
Run the test case by clicking on “Run” tab (1), choosing the test case (2) and click on “Start” button (3).
© 2012 LogiGear Corporation. All Rights Reserved
ResultResult
There are two ways to view the result: Report and Log. Click on them to launch the result html file.
© 2012 LogiGear Corporation. All Rights Reserved
ResultResult
Report file
© 2012 LogiGear Corporation. All Rights Reserved
ResultResult
Log file, you can see the log of steps there.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Settings tableSettings table
[Documentation] Used for specifying a test case documentation. The [Documentation] setting allows you to set a free
documentation for a test case That text is shown in the command line output, as well as the
resulting test logs and test reports.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Settings tableSettings table
[Suite Setup], [Suite Teardown], [Test Setup], [Test Teardown] , [Setup] and [Teardown] Specify Precondition and Postcondition at Suite/Test case level.
[Setup] or [Teardown] settings in the test case table override possible Test Setup and Test Teardown settings
Use value NONE to indicate that a test has no setup/teardown
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Settings tableSettings table
[Force Tags] All test cases in a test case file with this setting always get specified tag
[Default Tags] Test cases that do not have a [Tags] setting of their own get these tags.
[Tags] A test case always gets these tags. Use value NONE to override default tags
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Settings tableSettings table
[Test Template] Reducing duplication with data-driven tests. Instead of repeating the same keyword with all the tests in a file, it is possible to use it only once in the Setting table.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Settings tableSettings table
[Timeout] if a test or keyword is not finished within the specified time, the keyword that is currently being executed is forcefully stopped.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced FOR Loop FOR Loop
For loops can be used with both test cases and user keywords. Except for really simple cases, user keywords are better, because they hide the complexity introduced by for loops.
The basic for loop syntax, FOR item IN sequence
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced FOR Loop FOR Loop
For item in range
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced FOR Loop FOR Loop
Exit For Loop keyword can be used directly in a for loop or in a keyword that the for loop uses. In both cases the test execution continues after the for loop. If executed outside of a for loop, the test fails.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced RepeatRepeat
BuiltIn keyword Repeat Keyword takes a keyword and how many times to repeat it as arguments.
© 2012 LogiGear Corporation. All Rights Reserved
Advanced Advanced Test librariesTest libraries
Robot Framework's actual testing capabilities are provided by test libraries. There are many existing libraries, some of which are even bundled with the core framework, but there is still often a need to create new ones.
Robot Framework itself is written with Python and naturally test libraries extending it can be implemented using the same language.
When running the framework on Jython, libraries can also be implemented using Java. Pure Python code works both on Python and Jython, assuming that it does not use syntax or modules that are not available on Jython.
When using Python, it is also possible to implement libraries with C using Python C API, although it is often easier to interact with C code from Python libraries using ctypes module.
© 2012 LogiGear Corporation. All Rights Reserved
Refer documentRefer document
Robotframeworkhttp://code.google.com/p/robotframework/
Selenium action:http://robotframework-seleniumlibrary.googlecode.com/hg/doc/SeleniumLibrary.html?r=2.7
Build-in action:http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html?r=2.7.1
http://blog.codecentric.de/en/2012/01/robot-framework-ide-ride-overview/
User guide:http://robotframework.googlecode.com/hg/doc/userguide/RobotFrameworkUserGuide.html