The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework

The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
/ Today’s Tech News /
Recently,Google is improving its chatbot Bard, which can embed images in chat results. While images can indeed be provided in chat results, there is still a gap between the results and Bing chat. Although users can currently chat with Bard in English, Japanese, and Korean, image support in search results is currently only available in English.
/ Author Profile /
This article is contributed byMaike Aodebiao, mainly sharing the UI automation testingMaestro framework, which is believed to be helpful for everyone! Special thanks to the author for the wonderful article.
Maike Aodebiao’s blog address:
https://juejin.cn/user/2365804752418232
/ Introduction /
UI automation testing is a software testing method aimed at verifying whether the application’s user interface operates and interacts as expected. It tests the application’s functionality and user experience by simulating user actions on the application interface, such as clicking buttons, entering text, selecting options, etc.
For conventional testing methods, it is no different; during the product development cycle, testing occupies a significant amount of time. In the agile development model of 21 (one week of development, one week of testing, one hour of deployment), the testing period lasts up to a week. Why does it take a week?
During each development process, the testing operations needed are not just the existing version requirement tests; they also need to perform comprehensive testing, meaning all important parts need to be tested, and UI automation testing replaces this large number of repetitive operations that need to be executed in every version.
/ Advantages of UI Automation Testing /
  1. Improved Testing Efficiency: Automated testing can quickly execute testing tasks, making it more efficient than manual testing. It can execute a large number of test cases in a short time and can run tests on different operating systems and browsers.
  2. Increased Test Coverage: UI automation testing can cover various functions and user interaction scenarios of the application, ensuring the application runs correctly under different conditions.
  3. Support for Continuous Integration and Continuous Delivery: The automated testing framework can integrate with continuous integration and continuous delivery processes, helping teams run tests automatically after each code change, allowing early detection of issues.
  4. Improved Software Quality: With automated testing, potential issues and defects can be discovered and resolved earlier, enhancing software quality and stability.
/ What is its Value /
  1. Increased Software Development Efficiency: Automated testing can reduce the workload of manual testing, speeding up software development while enhancing the productivity of the development team.
  2. Quick Feedback: Automated testing can execute quickly, providing immediate feedback results, helping developers quickly locate and fix issues.
  3. Reduced Testing Costs: Although UI automation testing requires some initial investment, over time, it can significantly reduce testing costs, especially in long-term projects.
  4. Improved User Satisfaction: By ensuring the quality and stability of the application through automated testing, a better user experience can be provided, enhancing user satisfaction.
So, what are the common automated tests?
Generally, most developers use Python language, and the preferred development language for testing engineers is of course the first choice. What are the common automated testing frameworks?
/ Common UI Automation Testing Frameworks /
  1. Selenium: Selenium is one of the most popular UI automation testing frameworks, supporting various programming languages such as Java, Python, and C#. It can simulate user operations on the web and perform various testing tasks.
  2. Appium: Appium is an open-source UI automation testing framework specifically for testing mobile applications. It supports various mobile platforms like iOS and Android and provides cross-platform testing capabilities.
  3. Cypress: Cypress is a modern JavaScript front-end testing framework designed for end-to-end automated testing of web applications. It features an easy-to-use API and powerful debugging capabilities.
  4. TestComplete: TestComplete is a powerful UI automation testing tool supporting various application types, including web, desktop, and mobile applications. It offers rich testing features and easy-to-use script recording capabilities.
The necessity of UI automation frameworks is self-evident, but for small companies, their high cost can be prohibitive. Today, I want to introduce a new favorite that has a low cost. First, let’s take a look at a picture:
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
This is its official case; doesn’t it look exciting? Don’t worry, even more exciting things are coming:
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
Seeing this picture makes you even more excited. Its language composition is Kotlin, Script, Swift; aren’t these just the regular development languages? Isn’t this a boon for small companies? Why do I say that?
  1. The Development Language Determines That Client-Side Developers Can Handle It
  2. Hiring a Junior Testing Engineer is Sufficient; Any Issues Can Be Addressed by Developers
  3. Allows the Entire Client Team to Participate; Android and iOS Engineers Can All Contribute
/ Maestro /
Maestro is the easiest way to automate UI testing for your mobile app.
Why Choose Maestro
  1. Maestro is built on the learnings of its predecessors (Appium, Espresso, UIAutomator, XCTest), meaning it incorporates features that professional testing engineers have used; it was born in Rome.
  2. High Adaptability: UI elements are not always where you expect them to be, and screen clicks do not always go through, etc. Maestro embraces the instability of mobile applications and devices and strives to cope with it.
  3. Built-in Tolerance for Delays: No need to add sleep() calls in your tests. Maestro knows that loading content may take some time (e.g., through the network) and automatically waits (but not exceeding the required time).
  4. Extremely Fast Iteration Speed: Tests are interpreted and do not require compilation. Maestro can continuously monitor your test files and re-run them when they change.
  5. Powerful Syntax: Define your test scripts in files.
  6. Easy Setup: Maestro is a single binary file that works anywhere.
Its charm can perhaps only be fully understood through its official website. Here is the link:
https://maestro.mobile.dev/
Installation Environment
The following is for Mac environment:
In the Mac environment, there are two dependencies that must be installed:
  1. Xcode: Recommended version 14.x or higher, which can be directly downloaded from the App Store.
  2. idb_companion:
Official address:
https://github.com/facebook/idb
Install using brew:
brew tap facebook/fb
brew install idb-companion
After installing the above two environments, use the following code for installation:
Updates can also be done using this code:
curl -Ls "https://get.maestro.mobile.dev" | bash
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
This indicates that the installation is complete; then follow the prompts to configure:
    export PATH="$PATH":"$HOME/.maestro/bin"
Add to the environment.
Testing
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
After completion, Android does not require any other operations and connects automatically.
Usage
After setting up the environment, at any location, generally specifying the test folder, create a file ending with .yaml.
Simple Example
appId: com.xxx.android

---

- launchApp
Launch the APP with the specified package name.
Run
maestro test xxx.yaml
The result is that the APP with the specified package name opens.
Syntax Parsing
Official Demo
According to the official introduction, we can use the command to download its full sample.
maestro download-samples
Of course, you can also download directly:
https://storage.googleapis.com/mobile.dev/samples/samples.zip
iOS
cd ./samples
unzip sample.zip
xcrun simctl install Booted Wikipedia.app
maestro test ios-flow.yaml
Android
cd ./samples
adb install sample.apk
maestro test android-flow.yaml
Maestro Studio
Maestro provides a tool that can automatically help us write commands; it’s simply delightful.
  1. Ensure the device is connected.
  2. Run the command.
maestro studio
This generates a web workspace on the local specified port.
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
Then we can click to intuitively select UI elements to receive suggestions on how to interact with elements in the Flow, or enter Maestro commands in the REPL and run them by clicking ENTER.
Click the device screenshot to select a UI element.
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
Maestro Studio will automatically generate examples showing you how to interact with selected elements in Flows. You can double-click the example to execute it directly or copy it, read the documentation, and more using the available hotkeys.
You can execute commands directly in the REPL:
The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
Click to export, and you can save the automation script; just ask if you are afraid.
/ Conclusion /
This article delves into UI automation testing and its importance in software development, introducing several common UI automation testing frameworks such as Selenium, Appium, Cypress, and TestComplete. It particularly emphasizes the powerful tool based on these frameworks—the Maestro framework. The Maestro framework provides developers with a new set of syntax and tools, enabling them to create, manage, and execute UI automation testing scripts more easily.
Installing and configuring the Maestro framework is one of the key steps to using it. In this article, we provide a detailed guide to help readers easily install and configure the Maestro framework, laying a solid foundation for their work environment.
Simple script examples and an introduction to Maestro framework syntax are provided in this article to better demonstrate the capabilities and characteristics of the Maestro framework. Through this example, readers can understand the syntax and basic usage of the Maestro framework. We emphasize the flexibility and ease of use of the Maestro framework, as well as its advantages compared to other frameworks.
Maestro open-source address:
https://github.com/mobile-dev-inc/maestro
Recommended Reading:
My new book, “The First Line of Code, 3rd Edition,” has been published!
Deep dive into Composable functions, making you a Compose expert.
Enhance programming thinking; this is the learning method that saves you ten years of detours.
Feel free to follow my public account
Learn technology or submit articles

The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework

The Revolution of UI Automation Testing: Embracing the Future with Maestro Framework
Long press the image above to scan the QR code to follow

Leave a Comment