Today I will talk about how to use TestCat to automatically control your phone via javascript.
Preparation
- Install TestCat from github.
- Prepare an Android phone and turn on the Android debugging mode. (How to turn on the Android debugging mode)
- Open the TestCat, and connect the mobile phone and the computer PC through the data cable. Congrats, you're ready to test your cat!
Getting Started
1. Preview
Take a simple test case testing whack-a-mole as an introductory example.(TestCat supports English and Chinese)
1. New project
Click the 'File' button in the upper left corner, create a new project as shown below, and follow the prompts
2. Partial screenshots
- We pass the screenshot button on the upper right of the test cat device window
- Take pictures of the three moles on the left, middle and right
- Name and save it, and the corresponding image will be generated in the image directory
3. Coding
Let the TestCat continuously find out whether the mole appears on the screen of the mobile phone, and if it does, click on the location of the hamster and use the cat.tap('xxx.png')
interface. This interface will detect whether the corresponding picture appears on the current screen, if it appears, click it, otherwise nothing happens.
Double-click index.js
in the project, add the following code, you can continuously test the whack-a-mole
while(true){
cat.tap("Left mole.png")
cat.tap("Middle mole.png")
cat.tap("Right mole.png")
}
`
The above code constantly checks whether the current display content of the mobile phone has a picture related to the mole, and if so, click the center point of the picture.
congratulations! ! ! You have already fully started with the test cat~
More features
The TestCat is more than this. For more info, please check the API
Top comments (0)