# urs/bin/python
# encoding:utf-8
import time
from appium import webdriver
import unittest
class MyTestCase(unittest.TestCase):
def setUp(self):
self.desired_caps = {}
self.desired_caps['platformName'] = 'Android'
self.desired_caps['platformVersion'] = '7.0'
self.desired_caps['deviceName'] = '8223d2ed'
self.desired_caps['appPackage'] = 'com.doro'
self.desired_caps['appActivity'] = '.MainActivity '
self.desired_caps["unicodeKeyboard"] = "True"
self.desired_caps["resetKeyboard"] = "True"
self.desired_caps['automationName'] = 'Uiautomator2'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', self.desired_caps)
def cameraCase(self):
time.sleep(1)
self.driver.press_keycode(3)
time.sleep(1)
self.driver.tap([(359, 1247)])
time.sleep(1)
self.driver.tap([(359, 1247)])
time.sleep(2)
input = self.driver.find_element_by_id("com.doro.apps.launcher3:id/search_box_input")
input.send_keys("Ca")
time.sleep(1)
# self.driver.find_element_by_xpath("//android.widget.FrameLayout[contains(@content-desc ,'Camera')]").click()
self.driver.tap([(550, 500)])
self.driver.find_element_by_id("com.mediatek.camera:id/shutter_button_photo")
time.sleep(1)
self.driver.find_element_by_id("com.mediatek.camera:id/thumbnail").click()
time.sleep(1)
self.driver.get_screenshot_as_file("Camera shut.png")
def wifiCase(self):
self.driver.press_keycode(3)
time.sleep(1)
self.driver.flick(360, 0, 360, 1000)
time.sleep(1)
self.driver.tap([(550, 500)], 2)
self.driver.find_element_by_id("com.android.settings:id/switch_widget")
self.driver.find_elements_by_xpath("//android.widget.FrameLayout [contains(@content-desc,'CKT,,Wifi signal full')]").click()
password = self.driver.find_element_by_id("com.android.settings:id/password")
password.send_keys("ck88888!")
self.driver.find_element_by_id("android:id/button1").click()
def tearDown(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main()
![](/uploads/photo/2017/b66d5ad3-2a0b-4ed6-a512-1d3210fac116.jpg!large)
能看出是哪里出问题了吗?