38
Robot Framework – Basic Level. Date: 2011-10-03 Version: 1.0 Page 1

Robot Framework – Basic Level

  • Upload
    aldona

  • View
    250

  • Download
    0

Embed Size (px)

DESCRIPTION

Robot Framework – Basic Level. Date: 2011- 10 -0 3 Version: 1.0. Robot Framework - Introduction. Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD). . Robot Framework - Introduction. - PowerPoint PPT Presentation

Citation preview

Page 1: Robot  Framework –  Basic Level

Robot Framework – Basic Level.

Date: 2011-10-03Version: 1.0

Page 1

Page 2: Robot  Framework –  Basic Level

Robot Framework - Introduction

Robot Framework is a generic test automation framework for acceptance testing and acceptance test-driven development (ATDD).

Page 2

Page 3: Robot  Framework –  Basic Level

Robot Framework - Introduction

It has easy-to-use tabular test data syntax and utilizes the keyword-driven testing approach.

Page 3

Page 4: Robot  Framework –  Basic Level

Robot Framework - Introduction

Its testing capabilities can be extended by test libraries implemented either with Python or Java, and users can create new keywords from existing ones using the same syntax that is used for creating test cases.

Page 4

Page 5: Robot  Framework –  Basic Level

Robot Framework - 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 ability to create reusable higher-level keywords from the existing keywords. Provides easy-to-read reports and logs in HTML format. Is platform and application independent. The modular architecture supports creating tests even for applications with several

diverse interfaces. Provides a simple library API for creating customized test libraries. Provides a command line interface and XML based outputs for integration into existing

build infrastructure (continuous integration systems). Provides support for Selenium for web testing, Java GUI testing, running processes,

Telnet, SSH , Swing, and so on. Remote library interface enables distributed testing and implementing test libraries in

any programming language. Provides tagging to categorize and select test cases to be executed. Has built-in support for variables, practical particularly for testing in different

environments.

Page 5

Page 7: Robot  Framework –  Basic Level

Plugins and Libraries

FireFox: Firebug integrates with Firefox to put a wealth of development

tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

XPath Checker is a Firefox Extension for testing XPath expressions interactively.

Page 7

Page 8: Robot  Framework –  Basic Level

Plugins and Libraries

ROBOT (buil in): Selenium Library (used in the workshop). SeleniumLibrary is a

Robot Framework test library that uses the popular Selenium web testing tool internally. It provides a powerful combination of simple test data syntax and support for different browsers.

Database Library Database Library is a Robot Framework test library that provides common funtionality for testing database contents.

SSH Library It enables execution of commands on a remote machine over an SSH connection. It also offers possibility to transfer files from and to a remote machine.

Swing Library SwingLibrary is a Robot Framework test library for testing Java Swing applications.

Dialogs test library Dialogs is Robot Framework's standard library that provides means for pausing the test execution and getting input from users.

Page 8

Page 9: Robot  Framework –  Basic Level

Documentation – for example SeleniumLibrary

All keywords in SeleniumLibrary that need to find an element on the page take an argument, locator.

In the most common case, locator is matched against the values of key attributes of the particular element type.

For example, id and name are key attributes to all elements, and locating elements is easy using just the id as a locator

Page 9

Page 10: Robot  Framework –  Basic Level

How to find LOCATOR?

For example button <Szukaj w Google> from www.google.pl:

1. Click RMB on button <Szukaj w Google> 2. Choose Inspect element (Zbadaj element) from menu.

Page 10

Page 11: Robot  Framework –  Basic Level

How to start using ROBOT?

1. Run Selenium Server RC (click shortcut on desktop)

or from Terminal* : java -jar /usr/local/lib/python2.6/dist-packages/SeleniumLibrary/lib/selenium-server.jar -port 4444

2. Run RIDE:Shortcut „ctrl+i” or from Terminal* type ride.py

Tips: run Terminal – Aplications>Accessories>Terminal or shortcut „ctr+~” (tylda)

Page 11

Page 12: Robot  Framework –  Basic Level

1. Step - Creating new PROJECT

1. Create NEW PROJECT (File>New Project)

and select options:

Page 12

Page 13: Robot  Framework –  Basic Level

Add Libraries to PROJECT

Choose Project_name and add three LIBRARIES:

TIPS: Selenium Library is with argument value 15 – stands for 15 seconds timeout

Page 13

Page 14: Robot  Framework –  Basic Level

Test setup and teardown

Test setup and teardown Robot Framework has similar test setup and teardown functions as many other test

automation frameworks.

In short, a test setup is something that is executed before a test case and a test teardown is executed after a test case.

Page 14

Test setup:1. Open FireFox browser2. Go to www.allegro.pl

Test case:Run all test steps

in Test Case

Test teardown:Close browser

Page 15: Robot  Framework –  Basic Level

Teardown – what for?

Page 15

What makes a test teardown special is that it is executed also when a test case fails, so it can be used for clean-up activities that must be done regardless of the test case status.

Both a setup and a teardown can also easily be specified for all test cases in a test suite, so using them avoids repetition.

Page 16: Robot  Framework –  Basic Level

2 Step – Create Test Setup

1. Click RMB on Project_name > New User Keyword

Page 16

Page 17: Robot  Framework –  Basic Level

2 Step – Create Test Setup

2. Type in table:

ff – stands for FireFox browser

Page 17

Page 18: Robot  Framework –  Basic Level

2 Step – Create Test Setup

Tips: Start typing ‚Open Br..’ and then use ‚ctr+space’ for autocompletion.

Page 18

Page 19: Robot  Framework –  Basic Level

2 Step – Create Test Teardown

1. Click RMB on Project_name > New User Keyword

2. Type in script table:

Page 19

Page 20: Robot  Framework –  Basic Level

Adding setup and teardown - success

SelectTest Setup and Test Teardown into Project Settings Page

Page 20

Page 21: Robot  Framework –  Basic Level

SAVE

Save:Hit ‚ctrl+shift+s’or click (save button):

Page 21

Page 22: Robot  Framework –  Basic Level

Create new TEST CASE

Click RMB on Project_name > New test Case

Page 22

Page 23: Robot  Framework –  Basic Level

Excrsise 1 – Steps

1. Open FF and go to www.allegro.pl (this part is in Test Setup)2. Input text ROWER in search field.3. Click submitt button <Szukaj>4. VALIDATE: Results page schould contain text ‚ROWER’

Page 23

Page 24: Robot  Framework –  Basic Level

Excrsise 1 – Steps

1. Input steps into script table:

Page 24

Page 25: Robot  Framework –  Basic Level

Run test case

1. Select RUN bookmark2. Select checkbox for test case3. Hit ‚START’ and…

Page 25

Watch the magic….

Page 26: Robot  Framework –  Basic Level

View Report and Logs

After finish test case view Report and Logs

Report and Logs opens in browser.

Page 26

Page 27: Robot  Framework –  Basic Level

Exercise 1a (variables) – Steps

1. Copy exercise 1 test case2. In script: add new row (RMB>Insert Rows)

replace Value ‚Rower’ to ${item}

Page 27

Page 28: Robot  Framework –  Basic Level

Exercise - 2

1. Step:

Page 28

Page 29: Robot  Framework –  Basic Level

Exercise - 2

2. Step:

Input Text ${item}

DropBox:‚którekolwiek ze słów’

Chcechbox: ‚Szukaj równieżw opisach’ and ‚Odbiór osobisty’

Radiobutton: ‚Wszystkie województwa’

Page 29

Page 30: Robot  Framework –  Basic Level

Exercise - 2

Page 30

Page 31: Robot  Framework –  Basic Level

Creating User keywords

1. Click RMB on <Project_name> New User Keyword

2. Named it as ‚Find item’

3. Add new Argument ${item_name}

4. Hit <OK> New Keyword appears:

Page 31

Page 32: Robot  Framework –  Basic Level

Creating User keywords

1. Select all rows from Excercise 2 – copy to clipbord (ctr+c)2. Paste it to ‚Find item’ keyowrd

`

Page 32

Page 33: Robot  Framework –  Basic Level

Exercise 3 – using user keywords

Use ‚Find item’ keyword to build script Then on Results Page delete dynamic link (shown as button)

<Odbiór osobisty>

Page 33

Page 34: Robot  Framework –  Basic Level

Exercise 3 – using user keywords

Excercise 3 script:

Page 34

Page 35: Robot  Framework –  Basic Level

Excersise 4 - Loops

Find few items in one Test Case Script for Loop is:

Page 35

Page 36: Robot  Framework –  Basic Level

How LOOP works?

1.Find zegar2.Click link

• ${item_name} = zegar

1.Find kubek2.Click link

• ${item_name} = kubek

1.Find zeszyt2.Click link

• ${item_name} = zeszyt

Page 36

Page 37: Robot  Framework –  Basic Level

The End

Page 37

Page 38: Robot  Framework –  Basic Level

Page 38