UI testing is a type of testing, also known as user interface testing. Through this test, we check whether the interface of the application is working properly or whether there are any bugs that hinder user behavior and do not meet written specifications. It is important to understand how users will interact between users and the website to perform UI testing. By performing UI testing, the tester will try to imitate the user's behavior to see how the user will interact with the program, and to see whether the website is operating as expected and whether it is flawed.
In the last automated test series (2) , we generally introduced the concept of API testing and the practice in the pig tooth fish. This article mainly focuses on the concept introduction of UI testing and the practice in Choerodon.
The following is a detailed introduction to the UI test functions provided by Toothfish:
What is UI testing
UI testing covers the user interaction part, including the structure and visual parts of the website that users pay attention to. The web site contains many different web elements from CSS, JavaScript and many other languages. The website elements can be connected to the screen, keyboard, mouse, or any other tools the user uses to interact with the website. UI testing captures these elements and performs them Tests and declarations.
When performing UI testing, you need to pay attention to ensure that the application does not have any cross-browser compatibility issues. Because each browser uses a different browser engine, and may not support the same CSS features. Therefore, it is important to ensure that the UI is rendered seamlessly on all major browsers. Testing on different browsers is called cross-browser testing, which can help testers test their websites under multiple combinations of all major browsers and devices (including mobile phones, tablets, etc.).
How to choose manual or automatic?
Like any other type of testing, UI testing can also be performed manually or through automation. Manual testing requires testers to manually perform each test on each element. For example, a test input field will need to type different values again and again for any discrepancies. If the website UI has fewer components, it is best to conduct UI testing through a manual process and complete it quickly. But it is not suitable for complex websites. Websites with rich user interfaces make manual UI testing very inefficient, time-consuming and error-prone.
Scenarios suitable for UI automation testing
Not all test scenarios are suitable for automated testing. For this, you can refer to the following criteria to assist judgment:
- The needs of the project do not change frequently
- The UI of the page has entered a stable stage
- The project cycle is long enough
- A large number of regression test tasks
Among them, some projects are obviously not suitable for using UI automated testing, such as video players, music players and other software that are highly interactive and rely on strong concurrency.
Advantages of UI automation testing
The UI automation testing process simplifies the process of creating UI tests, running them, and viewing the results. There are many reasons why development and testing teams choose to automate UI tests. The most notable include:
- Time-Manual testing is very slow and cannot keep up with many development processes.
- Cost-Manual testing requires a lot of resources and is costly.
- Accuracy-When performing repetitive tasks, manual testing is prone to more errors. On the contrary, automation reduces the chance of these errors.
- Scale-When performing complex iterations, it is difficult to rely on manual testing.
- Trend-Most organizations have realized how to benefit from automated testing, so there is increasing pressure to jump on the trend of automation.
UI automation test design principles
- A test case completes a function point test (commonly used): a manual use case corresponds to an automated test case;
- A script is a complete scene;
- Scripts are independent and cannot be dependent (the scripts are isolated from each other): For example, use cases related to the login status: personal center, order details, order shopping, etc. If the scripts are not independent and dependent on each other, the login test script fails In the case of, it will lead to the destruction of the personal center, order details, and order shopping test scripts, and subsequent repair and maintenance costs will be high;
- Set up appropriate checkpoints: judge the success of the use case through assertions;
- Well-designed framework: Python commonly used test frameworks are unittest and pytest. Use frameworks and encapsulate common test modules to reduce the workload of automated test script maintenance;
Introduction to the WEB-side UI test tool
API test cases are mainly composed of 4 parts, namely: basic information of the use case, pre-steps, request scripts, and assertions.
UTF
UTF (Unified Functional Testing) = QTP (Quick Test Pro) + ST (Service Test) was developed by HP. It is an enterprise-level automatic test tool that provides powerful and easy-to-use recording and playback functions, and is compatible with two recognition methods, object recognition mode and image recognition mode, and supports software testing of B/S and C/S architectures. It is the current mainstream automated testing tool. It is mainly used for regression testing and testing of new versions of the same software.
Robot Framework
It is an automated testing framework written in Python language, with good scalability, keyword-driven support, can test multiple types of clients or interfaces at the same time, and can perform distributed testing.
Selenium
Selenium overview
Selenium is also a tool for web application testing. It supports multiple platforms, multiple browsers, and multiple languages to achieve automated testing. It is currently the most widely used in the field of web automation.
Selenium is one of the most widely used open source Web UI (user interface) automated test suites. It was originally developed by Jason Huggins in 2004 as an internal tool of Thought Works. Selenium supports automation across different browsers, platforms and programming languages.
Selenium features
- Selenium is an open source and portable web testing framework.
- Selenium IDE provides playback and recording functions for authoring tests without the need to learn test scripting languages.
- It can be regarded as a leading cloud-based testing platform that helps testers record their operations and export them as reusable scripts, and has an easy-to-understand and easy-to-use interface.
Selenium supports various operating systems, browsers and programming languages. The following list:
- Programming languages: C#, Java, Python, PHP, Ruby, Perl and JavaScript
- Operating system: Android, iOS, Windows, Linux, Mac, Solaris.
- Browser: Google Chrome, Mozilla Firefox, Internet Explorer, Edge, Opera, Safari, etc.
- It also supports parallel test execution, thereby reducing time and improving test efficiency.
- Selenium can be integrated with frameworks such as Ant and Maven for source code compilation.
- Selenium can also be integrated with testing frameworks such as TestNG for application testing and report generation.
- Compared with other automated testing tools, Selenium requires fewer resources.
- WebDriver API has tried to be integrated in Selenium, which is one of the most important modifications to Selenium.
- The Selenium Web driver does not require server installation, and the test script directly interacts with the browser.
- Selenium commands are classified according to different classes to make them easier to understand and implement.
- Selenium Remote Control (RC) is called Selenium 2.0 together with WebDriver API. This version is designed to support vibrant web pages and Ajax.
Three advantages of Selenium
- Speed: Time is the main resource of every company, and automated testing can save a lot of time. Selenium Automation tests require us to write tests only once, and then run them again and again, without any intervention with different values and different schemes.
- Accuracy: As long as the test is written correctly, the Selenium Automation test can help us execute the test correctly. The main disadvantage of manual testing is that it is prone to human error.
- Transparency: Selenium Automation testing also helps to quickly generate reports and share them with the team as soon as the testing is completed. On the other hand, manual testing requires time to extract the results and manually report the results to generate reports through software or manually.
Choerodon UI test
Install
If you use UI testing in Choerodon, you need to install Selenium IDE first.
Selenium IDE (Integrated Development Environment) is an open source Web automated testing tool under Selenium Suite. Unlike Selenium WebDriver and RC, it does not require any programming logic to write its test scripts, but only needs to record the interaction with the browser to create test cases. After that, you can use the play option to rerun the test case. Note: Selenium IDE is only available as a plug-in for Firefox and Chrome. It cannot record test cases on browsers other than Firefox and Chrome. The recorded test scripts can also be exported to programming languages such as C#, Java, Ruby or Python.
Firefox browser
- Open the URL => https://addons.mozilla.org/en-us/firefox/addon/selenium-ide/ , it will redirect to the official add-on page of Firefox.
- Click the Add to Firefox button.
Chrome browser
use
Use Selenium IDE to record and playback scripts on Chrome browser
1. Open the IDE, and the initialization interface is as shown in the figure:
2. Create and start recording, enter the recorded web address
3. After the recording is complete, right-click the test case to save or export. Selenium IDE saves all .side single files
The UI test in Choerodon is imported into the system through the side file recorded and generated in the Selenium IDE, and the corresponding test cases and steps are generated in the UI test interface; then the corresponding test file can be directly executed to test the interface UI operation, you can Visually see the generated test report.
Summarize
UI testing is an important part of the software testing cycle and an important driving force for improving user experience and customer satisfaction. Most end users care more about what they actually see and touch. Therefore, this is why the UI or user interface has become so important for UI testing.
This article was originally created by the Toothfish technical team, please indicate the source for reprinting: official website
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。