1. # -*- coding: utf-8 -*-
2. # @Time : 2021/5/1
3. # @Author : 大海
4. from appium import webdriver
5.
6. desired_capabilities = {
7. "platformName": "Android",
8. "deviceName": "127.0.0.1:62001", # adb devices 查看,这里使用的是夜神模拟器
9. "platformVersion": "7.1.2",
10. "appPackage": "com.jingdong.app.mall", # 京东app
11. "appActivity": ".main.MainActivity"
12.
13. }
14.
15. driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_capabilities=desired_capabilities)
16. driver.implicitly_wait(10)
17.
18. # 打印当前的activity
19. print(driver.current_activity)
20. # 打印当前的包名
21. print(driver.current_package)
22. # 等待activity,超时时长为10s
23. flag = driver.wait_activity('.main.MainActivity', 10)
24. print(flag)
25. # 点击同意
26. driver.find_element_by_id('com.jingdong.app.mall:id/bqd').click()
27. # 点击家具厨具
28. driver.find_element_by_id('com.jingdong.app.mall:id/ic').click()
29.
30. # driver.quit()