Sorted out some commonly used small commands
-
Exit Appium. After each script, remember to exit the Appium service, otherwise the next startup will report an error and the session will be different. driver.quit()
-
Appium1.4 and above can input Chinese in the input box, Adding two lines desired_CAPS [“unicodeKeyboard”] = “True” desired_CAPS [“resetKeyboard”] = “True” enables the default keyboard of appium and turns off the analog keyboard of the phone.
-
The simplest operation to swipe is driver.swipe(x,y,x,y,t), where xy is the beginning and xy is the end. T is the duration, which means it takes a few seconds to do this slide. I don’t have to write it.
-
Get content-desc.get_attribute (“name”) for the control
-
Android controls, id can also be repeated.
-
Completely empty the input field method, using the keyboard simulation delete.
Press_keycode (29,28672) #ctral+a select the contents of the input box swzj.press_keycode(112) # click delete
-
Appium can be operated with the physical keystroke code of Selenium on the PC. Driver.press_keycode () Fills the parentheses with the code for the PC keyboard
8. For controls that the UIAutomator doesn’t recognize, or for errors, use the getPagesource method and process the result to find your own. You can also use testhome boss’s framework to automatically search.
9. It is not only necessary to test the UI, but also to test whether the request sent by the phone is correct. Man-in-the-middle attack can be used to intercept the request and verify whether all the parameters sent are correct
10. You can use a middleman to get out of the back-end development interface and start scripting directly to the front end
11. You can use middlemen to catch all requests and return 500 or delay. Let’s look at the fault tolerance and crash probability of mobile app. 12. If the class location is very slow, or even several minutes, you can only change the id location.
13. Some pages are using UIAuto to fetch controls to report errors such as XML. You can do it with a simulator. You can get it