from appium import webdriver
import os
import time
import base64
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7.1'
desired_caps['devicesName'] = '192.168.50.101:5555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'
#声明driver对象
driver = webdriver.Remote('http:127.0.0.1:21503/wd/hub', desired_caps)
#1.获取手机的时间
driver.device_time
#2.获取手机宽高
driver.get_windows_size()
#3.点按手机的按钮
driver.keyevent(24)
#4.操作手机通知栏
driver.open_notifications()
#5.获取当前手机的网络
driver.network_connection
#设置手机网络
driver.set_network_connection(4)
#手机截图
driver.get_screenshot_as_file(os.getcwd() + os.sep + 'hello.png')
driver.close_app()
driver.quit()