One article 2500 words Robot Framework automated testing framework super tutorial

1. Introduction to Robot Framework

Robot Framework is a Python-based scalable keyword-driven automation framework for acceptance testing, acceptance test-driven development (ATDD), behavior-driven development (BDD), and robotic process automation (RPA). It can be used in distributed heterogeneous environments where automation requires the use of different technologies and interfaces. Supported by the Robot Framework Foundation. Many industry-leading companies use this tool in their software development.

Robot Framework is open and extensible. Can be integrated with almost any other tool, known for creating powerful and flexible automation solutions. Robot Framework is free to use without licensing fees.

2. Features of Robot Framework

1. RF supports an easy-to-use tabular syntax for creating test cases in a unified manner.

2. RF provides the ability to create reusable advanced keywords from existing keywords.

3. Provide easy-to-read HTML format results reports and logs.

4. Platform and application independent.

5. Provides a library for creating custom tests that can be implemented natively with Python.

6. Provides a command line interface and XML-based output files for integration into existing build infrastructures (continuous integration systems).

7. Supports testing web applications, rest APIs, mobile applications, running processes, connecting to remote systems via Telnet or SSH, etc.

8. Support the creation of data-driven test cases.

9. Has built-in support for variables, especially for testing in different environments.

10. Provide tags to categorize and select test cases to execute.

11. Support for integration: Test suites are just files and directories that can be version-controlled with production code.

12. Provide test case and test suite level setup and teardown.

13. The modular architecture supports the creation of tests, even for applications with multiple different interfaces.

3. Architecture of Robot Framework

Robot Framework is a general-purpose, application- and technology-independent framework. It has a highly modular architecture as shown in the diagram below.

Test data is in a simple, easy-to-edit table format. When Robot Framework starts, it processes data, executes test cases and generates logs and reports. The core framework knows nothing about the target under test, and the interaction with it is handled by the library. Libraries can use the API directly, or they can use lower-level testing tools as drivers.

4. Robot Framework application example

The following screenshot shows the test case and data file:

Results and log files:

 

5. Robot Framework installation

Robot Framework is implemented in Python, so Python needs to be installed. On Windows machines, make sure to add Python to your PATH during installation.

Installing Robot Framework with pip is easy:

The process of the installation command run:

After the installation is complete, use the following command to check the version:

6. Simple example of Robot Framework

The case contains 2 files:

Test_suite.robot file

Keywords.resource file

1) Create a robot file (the code is shown below):

*** Settings ***Documentation     A test suite for valid login.......               Keywords are imported from the resource fileResource          keywords.resourceDefault Tags      positive
*** Test Cases ***Login User with Password    Connect to Server    Login User            ironman    1234567890    Verify Valid Login    Tony Stark    [Teardown]    Close Server Connection
Denied Login with Wrong Password    [Tags]    negative    Connect to Server    Run Keyword And Expect Error    *Invalid Password    Login User    ironman    123    Verify Unauthorised Access    [Teardown]    Close Server Connection
2)创建一个关键字文件:
*** Settings ***Documentation     This is a resource file, that can contain variables and keywords....               Keywords defined here can be used where this Keywords.resource in loaded.Library           CustomLibrary.py

*** Keywords ***Connect to Server    Connect    fe80::aede:48ff:fe00:1122
Close Server Connection    Disconnect
Login User    [Arguments]    ${login}    ${password}    Set Login Name    ${login}    Set Password    ${password}    Execute Login
Verify Valid Login    [Arguments]    ${exp_full_name}    ${version}=    Get Server Version    Should Not Be Empty    ${version}    ${name}=    Get User Name    Should Be Equal    ${name}    ${exp_full_name}
Verify Unauthorised Access    Run Keyword And Expect Error    PermissionError*    Get Server Version
Login Admin    [Documentation]    'Login Admin' is a Keyword.    ...                It calls 'Login User' from 'CustomLibrary.py'    Login User    admin    @RBTFRMWRK@    Verify Valid Login    Administrator

end

Finally, I would like to thank everyone who has read my article carefully. Watching the rise and attention of fans all the way, there is always a need for ritual exchanges. Although it is not a very valuable thing, if you can use it, you can take it directly.

These materials should be the most comprehensive and complete preparation warehouse for friends who do [software testing]. This warehouse has also accompanied me through the most difficult journey. I hope it can also help you! Everything should be done as early as possible, especially in the technology industry, and the technical foundation must be improved. I hope to be helpful…….

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/124295682