__init__.robot files of Robot Framework

Introduction

Example

In the article about Templates a similar test was considered

*** Settings *** Documentation Flasky App Login Data-driven Test with ... Arguments Embedded to Keyword Name and ... Named Columns Resource users/users.resource Suite Setup Setup Suite Test Tags ui login Test Template Providing ${username} and ${password} Title Should Be ${expected} *** Variables *** *** Keywords *** Create Unique User &{unique_user}= Generate Unique User Set Suite Variable ${unique_user} Setup Suite Create Unique User Register User user=${unique_user} # To reduce variable names two new # variables are created here ${VALID USER}= Set Variable ${unique_user.username} Set Suite Variable ${VALID USER} ${VALID PASSWD}= Set Variable ${unique_user.password} Set Suite Variable ${VALID PASSWD} Test Setup Tasks Start Chromium Browser Test Teardown Tasks Close Browser Providing ${username} and ${password} Title Should Be ${expected} Open Browser To Login Page Log ${username} Log ${password} Input Username ${username} Input Password ${password} Submit Credentials ${title}= Get Title Log ${title} Should Be Equal ${title} ${expected} *** Test Cases *** USERNAME PASSWORD EXPECTED TITLE Valid Credentials ${VALID USER} ${VALID PASSWD} User Information - Demo App Invalid User Name invalid ${VALID PASSWD} Login Failure - Demo App Invalid Password ${VALID USER} invalid Login Failure - Demo App Invalid User Name and Password invalid invalid Login Failure - Demo App Empty User Name ${EMPTY} ${VALID PASSWD} Log In - Demo App Empty Password ${VALID USER} ${EMPTY} Log In - Demo App Empty User Name and Password ${EMPTY} ${EMPTY} Log In - Demo App Empty User Name Invalid Password ${EMPTY} invalid Log In - Demo App Invalid User Name Empty Password invalid ${EMPTY} Log In - Demo App

If there are a lot of similar tests, it makes sense to separate common tags and Test Setup into a separate __init__.robot file.

If Sute Variables were used, then for their availability from files nested in the directory, you need to use children=True

robot/ |-- tests | |-- __init__.robot | |-- invalid_login.robot | `-- valid_login.robot `-- resources |-- ui | `-- ui.resource `-- users `-- users.resource

*** Settings *** Documentation Flasky App Login and ... Registration Tests Resource ui/ui.resource Resource users/users.resource Suite Setup Setup Suite Test Tags ui *** Keywords *** Setup Suite Create Unique User Register User user=${unique_user} # To reduce variable names two new # variables are created here ${VALID USER}= Set Variable ${unique_user.username} Set Suite Variable ${VALID USER} children=True ${VALID PASSWD}= Set Variable ${unique_user.password} Set Suite Variable ${VALID PASSWD} children=True Create Unique User &{unique_user}= Generate Unique User Set Suite Variable ${unique_user} children=True Test Setup Tasks Start Chromium Browser Test Teardown Tasks Close Browser

Now you can write a suite test without some settings, and also with only one keyword - a template

*** Settings *** Resource users/users.resource Test Tags login Test Template Providing ${username} and ${password} Title Should Be ${expected} *** Variables *** *** Keywords *** Providing ${username} and ${password} Title Should Be ${expected} Open Browser To Login Page Log ${username} Log ${password} Input Username ${username} Input Password ${password} Submit Credentials ${title}= Get Title Log ${title} Should Be Equal ${title} ${expected} *** Test Cases *** USERNAME PASSWORD EXPECTED TITLE Valid Credentials ${VALID USER} ${VALID PASSWD} User Information - Demo App Invalid User Name invalid ${VALID PASSWD} Login Failure - Demo App Empty User Name and Password ${EMPTY} ${EMPTY} Log In - Demo App Empty User Name Invalid Password ${EMPTY} invalid Log In - Demo App

Banner image

Article author: Andrei Olegovich

Похожие статьи
Robot Framework
Architecture
Logs
__init__.robot
Create custom .py libs
Path to libs and resources
Keyword as decorator
Template
Parametrize
Demo with pywinauto
Banner image

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: