This article will help you get started with the PO mode in automated testing!

Automated testing plays an important role in thesoftware testing project team. At the same time, reasonable implementation of automated testing can effectively reduce error repair costs and improve work efficiency.

The following takes web automated testing as an example to illustrate the POM mode: Under the python+Selenium+pytest framework, completing the writing, management, running and reporting of automated test cases seems to be a very simple work process. As the project progresses, Especially under the agile project development method with frequent iterations, the low-quality test scripts implemented by some automated testers often lead to high code maintenance costs in the later period. Over time, the so-called automated testing seems to have forgotten the original intention.

A very practical way to solve the low quality of test scripts in POM mode. Let me introduce to you the thinking of POM separation model:

pom separation:

POM separation page-object-module-- is a kind of thinking.

Purpose of using POM: In order to solve the problem of frequent UI changes in the front-end, which results in increasing costs of test automation script maintenance.

POM idea: Separate page elements, business logic and test scripts into two different class files. Class A only writes page element positioning and encapsulation of business logic code operations, while class B only writes test scripts.

POM mainly has the following advantages:

  1. Separate the web ui object warehouse from the test script, and separate the business code from the test script.

  2. Each page corresponds to a page class, and the elements of the page are written into this page class.

  3. The page class mainly includes the element positioning of the page and the method of encapsulating the business operation code related to these elements.

  4. Code reuse, thereby reducing the amount of test script code.

  5. The hierarchy is clear and supports the development of multiple automated scripts, such as which pages each person writes without affecting others.

  6. It is recommended that page classes and business logic methods be given meaningful names to facilitate others to quickly write and maintain scripts.

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

Examples are as follows:

1. Test script

2. Business logic

3.Interface elements

4. Encapsulate again

5. Use the latest package content

It is said that a good start is half the success, and the same is true for the implementation of automated testing frameworks. Before the testing framework is implemented, we need to conduct comprehensive examination and filtering before we can design a good framework that can face the inevitable changes in UI elements. Sometimes our first thought is how to automate those functional modules that change less frequently. And for those functional modules that change frequently, is there any way to reduce the high cost of code adjustments in the future? It is necessary to achieve "the whole body is activated when the child falls", rather than "the whole body is affected by pulling one hair." Can we limit the change to one place and make it available to every test script associated with it? The answer must be absolutely unanimous ------- the POM model can help us achieve it.

If the web page element changes, we only need to make modifications in its corresponding class file, instead of having to search and update them one by one in multiple different scripts. This approach is the Page Object Model (POM), which helps improve code readability, maintainability, and reusability.

Finally, I would like to thank everyone who read my article carefully. Looking at the increase in fans and attention, there is always some courtesy. Although it is not a very valuable thing, if you can use it, you can take it directly!

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.
 

Insert image description here

Guess you like

Origin blog.csdn.net/myh919/article/details/133321902