1. Method one, using tap
Tap has two parameters, element position and hit duration.
The general syntax is this tap ((x1,y1), (x2,y2)],100), we use the Tap method to click on the camera button for example through the mobile phone Baidu.
1. Element positioning
Remember the above element coordinates, which need to be used below.
2.tap Code Implementation
- Import OS
- Import time
- From Appium import Webdriver
- Desired_caps ={ ' platformname ': ' Android ',
- ' platformversion ': ' 6.0.1 ',
- ' devicename ': ' Kiw-al10 ',
- ' noreset ': True,
- ' apppackage ': ' Com.baidu.searchbox ',
- ' appactivity ': ' com.baidu.searchbox.SplashActivity ',
- ' Unicodekeyboard ': True,
- ' Resetkeyboard ': True
- }
- Driver = Webdriver. Remote (' Http://localhost:4723/wd/hub ', desired_caps)#启动app
- Time.sleep (3) #app启动后等待3秒, convenient element loading complete
- #模拟手指点击操作
- Driver.tap ([(918,413), (1026,521)], + )
Explanation: The element point coordinates of the position in the tap method above are obtained through the UI Automator Viewer, duration 100 means 100 milliseconds.
Above article source:
http://blog.csdn.net/u011541946/article/details/77986197
Click action in Appium