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