Robot Framework is supported by Robot Framework Foundation. Many industry-leading companies use this tool in their software development.
Robot Framework is open and extensible. Robot Framework can be integrated with almost any other tool to create powerful and flexible automation solutions. Robot Framework is free to use without licensing fees.
Robot Framework has a simple syntax, using human-readable keywords. Its functionality can be extended with libraries implemented in Python, Java, or many other programming languages. Robot Framework has a rich ecosystem including libraries and tools developed as independent projects.
01 Robotframework environment construction
Install python3.6 or above, and ensure that the environment variables are configured correctly
Install the robotframework library
pip install robotframework
Install the robotframework ride script GUI editor
pip install robotframwork-ride
Click Yes, a shortcut icon will be created on the desktop
02 Built-in keyword library
After robotframwork is installed, it will appear in the Lib/site-packages directory of the python installation directory
The libraries directory is the source code of keywords that we will use when writing scripts in the future
These keyword libraries are organized according to certain categories
Builtln
Variable definition, loop control, data calculation, binary conversion, assertion judgment, log, etc.
Collections
Handling related operations on python lists and dictionaries
DateTime
Operations related to handling date and time conversions
Dialogs
Provides methods to pause execution and get user input
OperatingSystem
Provide keywords related to the operating system
Process
Keyword related to the operation process
Remote
Special libraries act as proxies between Robot Framework and libraries elsewhere. The actual library can run on different machines and can be implemented using any programming language that supports the XML-RPC protocol
Screenshot
Provides keywords for taking screenshots of the desktop
String
Libraries for generating, modifying and validating strings
Telnet
Can connect to Telnet servers and execute commands on open connections
XML
Libraries for generating, modifying and validating XML files
03 Basic description of ride
Double-click the desktop ride icon to open the ride interface
01 Project Creation
Click File->New Project and select the directory because the test suite can be created under the project of the directory. If tpye is fifile, only test cases can be created, which is not conducive to the management of use cases
02 Create a test suite
A test suite is a collection of test cases used to manage
Right-click to select the project name, New Suite, and select fifile because the test case can be created under the test suite of the fifile. If tpye is the directory, you have to continue to build the test suite of the fifile to create the test case, because the test case only Can be created under fifile type
03
Create test cases
Right-click on the test suite and click New Test Case
04
Test Suite Workspace Description
1. The test suite Edit is divided into 4 parts
Settings area
The setting area is hidden by default, and it will appear when you click it.
Documentation:
Documentation, for each item. You can add documentation to the current object
Suite Setup:
Refers to the execution of a keyword when the test suite starts.
(Example: I set Sleep | 5sec in Suite Setup, which means to wait for 5 seconds. Note that the parameters of the keyword should be separated by |)
Suite Teardown:
Refers to the execution of a keyword when the test suite ends
Test Setup:
Refers to the execution of a keyword when the case is started
Test Teardown:
Refers to the execution of a certain keyword when the case ends
Test Template:
Test template, this is a template that can specify a keyword as the template for all TestCases under this test suite, so that all TestCases only need to set the incoming parameters of this keyword.
Test Timeout:
Set a timeout for each test case, after which it will fail and stop the case from running. This is to prevent certain situations that cause the case to keep getting stuck, neither stopping nor failing
Force Tags:
In the file-type Suite, you can continue to add Force Tags to the child elements, but he cannot delete the tags set by the parent element.
Default Tags:
The default tag, in fact, is no different from Force Tags
reference area
Mainly used to load external files
Library: Load the test library, mainly the test library in [PYTHON directory]\Lib\site-packages
Resource: Load resources, mainly resource files related to your project
Variables: load variable files
parameter area
Mainly used to define the internal variables of the suite
Add Scalar: define ordinary variables
Add List: Define list variables
Add Dict: Definition dictionary
data area
Mainly to display the defined content in the report and log, the format is the same as the document
2. Test suite Text Edit area
Test suite test case text information
3. Test suite Run area
Execution Profifile:
Select the running mode, which includes pybot, jybot and custom script. The default pybot is enough.
Start:
Run the case. If there is no check before the test cases under the test suite, all the test cases under the test suite are executed by default. If the test case is checked, execute the test. See the checked case below.
Stop:
Stop the case.
Report and Log:
Reports and logs must be run before they can be clicked. The difference between them is that the report is more of a display of results, the log is more of a process record, and more of a log is used.
Autosave:
Automatically save, if not checked, if the case is not saved after modification, it will prompt whether to save when running the case. If checked, it will be automatically saved at runtime.
Arguments:
Parameters of pybot (or jybot, etc.). The parameters of the full version can be entered on the doc command line by typing pybot.bat --help
Only Run Tests with these Tags:
Only run these marked test cases. You can add tags in the setting of the case
Skip Tests with these Tags:
Skip these marked test cases. You can add tags in the setting of the case
05 Test Case Workspace Description
1. The test case Edit area is mainly divided into 2 parts
Settings area
Documentation:
Documentation, for each item. You can add documentation to the current object.
Setup:
Refers to the execution of a certain keyword when the case is started.
Teardown:
Refers to the execution of a certain keyword when the case ends.
Tags:
Mark a test case. In the Run area, Only Run Tests with these Tags and Skip Tests with these Tags will use this flag to identify whether to run or skip the use case.
Timeout:
Set a timeout for each test case, after which it will fail and stop the case from running. This is to prevent certain situations that cause the case to keep stuck, neither stop nor fail.
Template:
Test template, this is a template that can specify a keyword as the template for all TestCases under this test suite, so that all TestCases only need to set the incoming parameters of this keyword.
table area
This is where the test cases are written
2. There is no difference between Text Edit and Run areas and test suites
04 robotframwork basic grammar
01 Log Chinese garbled processing
Find Lib\site-packages\robotide\contrib\testrunner\testrunnerplugin.py in your python installation directory, open the above file, find line 565, copy first, then comment, paste and modify on another line
Restart ride after modification
02
Use case internal variables
1. Ordinary variables
Ordinary variable definitions need to use the Set Variable keyword. The first cell refers to the variable name, and the last cell 10 refers to assigning 10 to the variable a.
Log is the log keyword and outputs the value of a
run it
2. List variables
List variable definitions need to use the Create List keyword
List definitions can be used in two ways:
${xxx}
@{xxx}
3. Dictionary variable
Dictionary variable definitions need to use Create Dictionary
Dictionary definitions can be used in two ways:
${xxx}
&{xxx}
03
Collection public variables
There are some public variables that are used in the same test set, so they can be defined in the set
add a normal variable
add a list variable
add a dictionary variable
Use of public variables
The public variables of the collection are available in every test case below him
Result after running:
04
Judgment
Case: Given a score, if the score is greater than 90, the output is excellent, if it is greater than 80, it is good, if it is greater than 70, it is fair, if it is greater than 60, it is a pass, and the others fail.
Use of Run Keyword If
05
cycle
Case 1: Calculate the sum of numbers within 100
FOR…IN RANGE xxx … END structure
${i} is equivalent to loop variable
Evaluate means sum + {sum}+The calculation result of s u m + {i} is assigned to ${sum}
Case 2: Even numbers in output list
FOR … IN xxx … END structure
${i} is equivalent to loop variable
Run Keyword If is to judge that the current loop variable is a multiple of 2, then output
Case 3: Skip the current loop, traverse the list, and skip if it is a multiple of 5
Continue For Loop If means skip this loop if the condition is met
Case 4: Traverse the list and terminate the loop if it hits 5
Exit For Loop If means to terminate the loop if the condition is met
06Keyword
library import
When you need to use some extended keywords, you need to import the corresponding library first. For example, the library for list and dictionary operations is Collections
Import Collections
Select the test collection, note that if it is displayed in red after importing, it means that the import is incorrect
Using Keywords in Collections
07
User keywords
User keyword is a custom keyword, which is equivalent to encapsulating a function when writing code
1. Ordinary variables as input parameters
Case: Encapsulate a calculation of the sum of all numbers within a specified number, such as within 100, within 1000, etc.
Create keywords
call keyword
If you want to call a custom keyword in a test collection, you need to import it first
Import custom keywords
After the import, the explicit green color indicates that it is correct, and the explicit red color indicates that the imported resource path is incorrect.
call keyword
Call the keyword written by yourself in the test case
2. List variables as input parameters
Case: Encapsulates an even number that returns the given list
Create keywords
call keyword
3. Dictionary variables as input parameters
Example: Define the grades of each language subject as a dictionary {'python':95,'java':58,'c':70}, encapsulate a keyword to change the failing scores to 60
Create keywords
call keyword
4. Multivariate input parameters
Case: encapsulate a keyword that calculates the sum of three numbers, the default value of the third number is 10
Create keywords
call keyword
For parameters with default values, they can be passed or not passed when calling