Automated Testing of robot framework (4) --- stratified thinking

Source: Internet
Author: User

When talking about the concept of robot framework layering, you have to mention "keyword-driven ".

 

Keyword-driven: Different call keywords lead to different test results.

The method described in the selenium API in the previous section is actually a keyword. For example, "Open Browser" is a keyword. From the bottom layer, it is a method to realize through programming.

Def open_browser (URL, browser): # Find the corresponding browser driver through browser, call the browser, and pass the URL to the browser through the httplib and urllib modules of Python. To achieve the goal of open brwoser.

The underlying layer of the "keyword" expressed through the above pseudo code is actually a program-defined method.

 

Back to the idea of hierarchy, the design pattern should be emphasized in programming. In fact, the design pattern is to use abstraction and encapsulation as needed, but it is actually a layered ideology. Divides an implementation process into multiple layers. Improved flexibility to achieve scalability and maintainability.

 

Back to the automation topic, we can encapsulate the operation steps in a method (keyword) and call the keywords to implement the test case.

 

Http://www.cnblogs.com/fnng/p/3871712.html

Refer to Section 1 of this series to create a Baidu search test case.

I want to write five Baidu search cases:

 

You can create five test cases under the search test suite. In fact, for each test case, the search content is different, and the script steps are the same. This will undoubtedly increase the redundancy of scripts, which is not easy to maintain. If the Positioning Method of the Baidu input box has changed, I have to open each use case and modify it.

 

We can solve this problem by creating keywords to achieve the idea of layering.

 

Robot framework keywords

 

1. Create Resources

Right-click "test project" and choose "New Resource" to create a resource.

Enter the Resource Name:

 

 

 

2. Create keywords

Right-click "Business keyword" and select "new user keyword" to create a user keyword.

 

Enter the keyword Name:

 

 

 

3. Edit keywords

 

Analysis:

For a test case, the user is concerned with what content is input and what results are obtained.

Therefore, for the "Baidu search" keyword, you need to create two interface variables $ {search} and $ {result} to receive the input content and expected results.

Click the arguments input box to define variables. Multiple variables are separated by "|.

 

Use parameterized variables in Baidu users.

 

 

 

4. Add the created Resource

Switch to the test kit (searchpipeline page, pipeline Resource (Business key word. txt)

 

 

5. Call keywords

Now you can use the created keywords in the test case (Baidu search ).

 

 

For each use case, call the "Baidu search" keyword, enter the search content, and enter the expected results. Different users care about how the use cases are executed. If the positioning of the Baidu input box changes, you only need to modify the keyword "Baidu search" without making any changes to each use case. This greatly improves the maintainability and scalability of use cases.

 

 

Further layered design:

 

 

At this point, the robot framework + selenium automated testing is rough. Of course, more APIs are used, and the detailed settings are not described. But we can use it for automation.

 

 

Automated Testing of robot framework (4) --- stratified thinking

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.