Why Use Selenium for Automated Testing

The problem with manual testing

Doing by manual operation relies on the response and intelligence of the human brain, why not use your hands to click? Hands will be sore, brain will be tired, and it will take up too much time. Think about why you learn automated testing. We all hope to use tools to free our hands, brains, and eyes.

Why use automation

Automation refers to the process of automatic detection, information processing, analysis and judgment, manipulation and control of machines, equipment, systems or processes (production, management processes) without the direct participation of people or fewer people, according to people's requirements, to achieve the expected goals process.
We usually come into contact with a lot of automation tools, such as the button wizard to automatically add blood and mana, and search engines. Before finding an article, we had to spread out all the information and turn it page by page. Now it is directly listed. The following searches can be implemented in the editor.
After using the automated test software, I still feel that it is not enough, because some test requirements are more complicated, including dozens or hundreds of steps, which cannot be tested by software, and even if it can be realized, it will be more troublesome. At this time, the problem we face is: use software to customize The transformation is not high, and it cannot be realized for complex scenes.
The customization of the code is very high, and you can implement what functions you want to achieve by yourself. What about those testers who can't program after the implementation? We can't let them idle, we have to write a test platform so that students who don't know how to code can use it easily.
Automated testing is the use of machine systems to verify the correctness, integrity, safety and quality of software. Our goal is to replace our daily manual testing work by writing code, requiring you to master the use and implementation principles of programming languages ​​​​and related code libraries as much as possible.

These are very easy to become a common test question in the interview. I usually like to collect these high-frequency questions. I have the interview experience of some big bosses in the first-tier factories, and some interview questions when I first entered the industry. .

Choose the right test method

The purpose of automated testing is not to completely replace manual testing, but to liberate manual work, so that people no longer repeat boring work every day, hand over these boring tasks to automated programs, and people turn to more creative work .
The testing work in a project is mainly divided into the following categories:

  • 1. Exploratory manual testing
  • 2. Manual testing that relies on scripts
  • 3. Test tools for generating scripts
  • 4. Code method

Most of the time, it's a combination of these four, but how do we distribute the four? Is there a pattern that allows us to arrange these four ways reasonably?

When to introduce automated testing

Automated testing does not come out of thin air, it needs to be built on the basis of manual testing. Typically, testing teams have already implemented several rounds of manual testing before introducing automated testing.

This kind of manual testing can be done in an exploratory manner, and more of a manual test that relies on scripts. We will design the operation script of each use case according to the use case design method, and then execute each use case according to the script.

When there are more and more use cases and the product iteration cycle remains unchanged, one day, the existing team cannot execute all the use cases before going online, and we need a more efficient way to execute use cases. At the same time, testers always need to execute the same use cases repeatedly, and they will feel tired after a long time. We will also find ways to hand over some boring work to automated programs for execution.

So, when to introduce automated testing? In fact, when the test team has difficulty coping with so many use cases, it transitions to the automated testing stage by selecting some use cases that are suitable for automated program execution.

Test tools represented by Jmeter

jmeter has a high status in the testing field. Its performance is stable and its expansion ability is strong. It can support multi-faceted testing such as interface testing, web page testing, and performance testing, and its operation is not very complicated.

Therefore, many test teams usually try to use Jmeter for automated testing before using code to build a testing framework. I will not talk about the specific operation method here, please chat privately if you are interested.

If it is a very small test team and does not have much technical reserves for code maintenance, it is more appropriate to use a test framework or an existing platform.

But this method is not very friendly to test practitioners. For example, if you change a company and this company no longer uses the previous tools, you will encounter relatively big troubles when looking for a job. In the field of technology, new tools emerge every day, challenging the market position of existing tools. Each company tends to choose different technologies. To find a common way to deal with interviews and recruitment, it is the tester problems faced.

My personal idea is to be proficient in one or two testing tools with a very high market share. When you encounter a new tool in the future, you can simply learn it. Unless it is needed by an existing company, you don’t need to spend too much thought on testing tools with a low market share. They may provide a lot of functions that look powerful, and you can learn their ideas, but they may not be used in the company.

Programming ability is both important and not important

Programming can be said to be the panacea way to solve automated testing. The flexibility provided by programming is unmatched by all existing tools. As long as the technology allows, you can implement almost any testing tool and cover any testing scenario through programming.

Then why do you say that programming is not important? Because no matter what method is used, the purpose of automation is to liberate manpower. If a test team spends a lot of energy programming, covers a variety of test scenarios, and invests a lot of manpower, material resources and money, but the effect is the same as before, it is right. The shackles of talents, not the liberation of manpower.

In the field of programming, you can use existing frameworks, stand on the shoulders of giants, and implement automated testing. For example, you can use selenium to implement automated testing of web pages. If one day Selenium is no longer popular, you can quickly transfer its implementation ideas to other frameworks. As long as you have programming skills, don't panic.

Why Selenium

At present, in web automation testing, the following frameworks are mainly used:

  • Selenium
  • Cypress
  • Playwright
  • Puppeter

I have been exposed to these frameworks or tools, and when the opportunity is right, I will write specific operation notes. Although there are many challengers, Selenium is still the most used, and its technical architecture is constantly evolving. Some people say that selenium is outdated, and they are right, it is indeed a bit old, but if I choose a model, I will still choose selenium first.

Before learning it, just ask a few questions:

  • Can Selenium solve web automation testing problems?
  • Is Selenium easy to learn?
  • Is Selenium data rich?
  • Is Selenium easy to migrate and scale?
  • Is Selenium easy for team collaboration?

I can always get an affirmative answer. Of course it also has some shortcomings, but these shortcomings are harmless now, Selenium's current shortcomings:

  • Screenshots, recording, and backtracking are inconvenient
  • no traffic interception
  • no mock
  • It will be recognized in anti-climbing, and of course other tools are also.

In any case, Selenium is just an automation auxiliary tool, and you need to have a clear understanding of him: selenium is just a browser automation tool that needs to be used in conjunction with testing tools. Selenium can't improve your testing level to help you quickly locate bugs

There is no best technology, only the right technology

I have roughly listed the issues that need to be considered when choosing a technology. Whether a technology is new or good-looking can of course be used as a reference indicator, but you can also look at something more practical: whether it can solve your problem

  • 跑 Demo
  • Environment build
  • low learning cost
  • friendly documentation
  • rich tutorial
  • perfect solution
  • a large number of cases
  • perfect ecology
  • active community
  • update active
  • Mature API
  • Enterprises are very willing to use, a large number of recruitment positions
  • Easy to migrate and expand
  • Support multiple platforms
  • Support multiple languages
  • Is it open source
  • Facilitate teamwork
  • manual testing team
  • development team
  • can you accept his flaws
  • No technology is perfect
  • There is no best testing tool, no best testing language
  • only suitable scene

Web automated testing is not efficient

The main purpose of automated testing of the entire web terminal is to be closer to the user's usage scenario, because the interface is the carrier for the user to directly contact with the software. Almost all user operations are realized through ui, so ui testing can best simulate the actual user usage. To perform ui testing, you need to stand on the user's standpoint, consider the user's pain points, and simulate the user's behavior to operate. Users use the functions of the product to obtain certain capabilities, so test cases should be designed through functionality, rather than simply considering product features and descriptions.

There are two problems with testing on the web side. The first is that the front-end interface changes rapidly, and the second is that the execution efficiency is low. Only optimization can be achieved through existing technical means, but these two problems cannot be avoided. Special attention should be paid when doing automated testing.

Finally a tutorial to help you!

This information should be the most comprehensive and complete preparation information for [software testing] friends. In order to better organize each module, I also refer to many high-quality blog posts and projects on the Internet, and try not to miss every single one. Knowledge points, these materials also accompanied me through the most difficult road, I hope it can help you too! ! !

insert image description here

Guess you like

Origin blog.csdn.net/weixin_56331124/article/details/130374678