from appium import webdriver
import unittest
import os
#from appium import SauceTestCase, on_platforms
from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
from time import sleep
#@on_platforms(platforms)
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class SimpleAndroidSauceTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '8.0.0'
desired_caps['deviceName'] = '小米手机'
desired_caps['app'] = PATH(
# 测试包在d盘,名字是test
'd:/test.apk'
)
# 本地需要开一个 127.0.0.1:4723 的appium服务;
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def test_create_note(self):
#此页面是权限请求页面,id也是系统的id
el = self.driver.find_element_by_id("android:id/button1")
el.click()
# cmd命令中输入找到当前activity:adb shell dumpsys activity activities
# 等待想要的页面出现
self.driver.wait_activity(".main.SelectSexActivity", 30)
# 包里面的id都和系统id 有区别
el = self.driver.find_element_by_id("com.xtoolapp.bookreader:id/select_sex_girl_tv")
el.click()
el = self.driver.find_element_by_id("com.xtoolapp.bookreader:id/select_sex_next_tv")
el.click()
el = self.driver.find_element_by_id("com.xtoolapp.bookreader:id/fixed_bottom_navigation_container")
el.click()