实现新增笔记测试实现新增笔记测试--有道云
# v1.0 实现新增笔记测试
import time
from appium.webdriver.webdriver import WebDriver
from selenium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
class yd_addnote:
def __init__(self):
# 使用初始化方法设置参数
self.caps = {}
self.caps["automationName"] = "UiAutomator2"
self.caps['platformName'] = 'Android'
self.caps['platformVersion'] = '6.0'
self. caps['deviceName'] = '192.168.144.101:5555'
self.caps['appPackage'] = 'com.youdao.note'
self. caps['appActivity'] = '.activity2.MainActivity t131'
self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)
self.driver.implicitly_wait(10)
# 新增笔记的测试
def test_add(self):
# 等待10秒,直到对象x出现
el=WebDriverWait(self.driver,10).until(lambda x:x.find_element_by_id('com.android.packageinstaller:id/permission_allow_button'))
# # 假如对象el出现
if el:
# 点击允许按钮
self.driver.find_element_by_id('com.android.packageinstaller:id/permission_allow_button').click()
# 点击新增按钮
self.driver.find_element_by_id('com.youdao.note:id/add_note').click()
# 点击新建按钮
self.driver.find_element_by_id('com.youdao.note:id/add_note_floater_add_note').click()
# 点击取消按钮
self.driver.find_element_by_id('com.youdao.note:id/btn_cancel').click()
# 输入内容
self.driver.find_element_by_xpath('//*[@resource-id="com.youdao.note:id/note_content"]/android.widget.EditText').send_keys('textcontent')
# 输入标题
self.driver.find_element_by_id('com.youdao.note:id/note_title').send_keys('titlle')
# 点击完成按钮
self.driver.find_element_by_id('com.youdao.note:id/actionbar_complete_text').click()
def check_addnote(self):
title=self.driver.find_element_by_id('com.youdao.note:id/title').text
print(title)
if __name__ == '__main__':
yd_addnote_obj=yd_addnote()
yd_addnote_obj.test_add()
yd_addnote_obj.check_addnote()
|