After reviewing the pre-2021 technology review, and having previously studied some of Cypress’s front-end automation technologies, I found myself not being the most popular front-end automation technology in China or the rest of the world, so I was intrigued to go down the drain.

Of course, this article is not intended to be too much of a summary of ourselves, but rather some of my thoughts and practices on developing automated tests or crawlers using ourselves.

For details, see playwright.bootcss.com/

So let’s start to elaborate on some of the feelings in the field.

contrast

In view of the cypress, here is a series of comparisons between cypress and ourselves.

The same

  • Node acquisition, not exactly the same, can only be said to be exactly the same. Each is done by selector or XPath of the node element.
  • Events are basically supported, such as click, press, etc.
  • It also has the ability to listen to interfaces.
  • Test report generation.
  • Snapshot function.
  • And so on…

Basically, the functions of automated test tools are similar, and the general function is similar.

different

  • The first and biggest difference, of course, is What makes CodeGen, or code generator, ourselves different, which we’ll discuss next.
  • In terms of interface monitoring, the ourselves may be configured with ourselves listening on all interfaces at once, while Cypress may be configured with ourselves listening on an interface at a time. So, in processing the data, the offender will be treated differently, with the benefit of not writing too much listening.

Codegen Code generator

By turning on the code generator on NPX CodeGen, the code generator has greatly improved the efficiency of our front-end automated tests by being able to generate ourselves in bit by bit.

In it, each action you make on the page generates code in the right column, which is also multilingual because the right pane itself supports multiple languages.

Note: here is a small pit operation is not available, the page is not documented, as we usually have some hover in the navigation bar shows the operation, but the page is not recorded, because he does not record the movement of the mouse, can only record some artificial operation, such as clicking, keystroke events, and so on.

Practice note

  • As mentioned above, CodeGen only records human actions, such as clicks, keystrokes, etc., so we need to add additional events to the code.
  • Asynchrony of the code, because the code is asynchronous, sometimes we need to wait through waitForTimeout.
  • Interface listening, we need to do data processing in the same place.
  • As we all know, our browser is basically already support multi-process, if you want to carry out a large amount of data crawler, you can consider opening multiple pages to obtain data, do not like me at the beginning of a silly process to obtain data, very inefficient (manual dog head).

conclusion

After all, few of us spend a lot of time writing automated tests, or even if I wanted to, most of the time the company wouldn’t. That’s why I’ve been slow to write automated tests. We will keep adding more advanced apis in this post as well. Thanks for watching, Goodby