风枫 发表于 2019-9-26 16:37:10

有道云任务-修改笔记,我调试的时候在修改笔记的内容的时候,模拟器调试修改的字符...

这是修改笔记的代码
#修改笔记
from appium.webdriver.webdriver import WebDriver
from youdaoyun.addnote_work1 import yd_addnote
import time
class yd_editnote(yd_addnote):
    def __init__(self):
      self.caps = {}
      self.caps['platformName'] = 'Android'
      self.caps['platformVersion'] = '6.0'
      self.caps['deviceName'] = '192.168.165.101:5555'
      self.caps['appPackage'] = 'com.youdao.note'
      self.caps['appActivity'] = '.activity2.MainActivity t82'
      self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)
      self.driver.implicitly_wait(10)
    def edit_note(self):
      self.driver.find_element_by_id('com.youdao.note:id/title').click()
      self.driver.find_element_by_id('com.youdao.note:id/edit').click()
      # 修改内容
      self.driver.find_element_by_xpath("//*[@resource-id='com.youdao.note:id/note_content']/android.widget.EditText").send_keys('editc')
      # 输入标题
      self.driver.find_element_by_id('com.youdao.note:id/note_title').send_keys('editt')
      # 点击完成
      self.driver.find_element_by_class_name('android.support.v7.widget.LinearLayoutCompat').click()
      # driver.find_element_by_class_name('android.widget.ImageButton').click()
      time.sleep(3)
    def check_editnote(self):
      retitle = self.driver.find_element_by_id('com.youdao.note:id/note_title').text
      print(retitle)
      if(retitle=='editt'):
            print("修改成功")
      else:
            print("修改失败")
      time.sleep(3)
if __name__ == '__main__':
    editnoteobj = yd_editnote()
    editnoteobj.test_addnote()
    editnoteobj.check_addnote()
    editnoteobj.edit_note()
    editnoteobj.check_editnote()
这是添加笔记的代码
#面向对象思想设计
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['platformName'] = 'Android'
      self.caps['platformVersion'] = '6.0'
      self.caps['deviceName'] = '192.168.165.101:5555'
      self.caps['appPackage'] = 'com.youdao.note'
      self.caps['appActivity'] = '.activity2.MainActivity t82'
      self.driver = WebDriver('http://127.0.0.1:4723/wd/hub', self.caps)
      self.driver.implicitly_wait(10)
    def test_addnote(self):
      ele = WebDriverWait(self.driver,10).until(lambda x:x.find_element_by_id('com.android.packageinstaller:id/permission_allow_button'))
      if ele:
            #允许按钮
            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_id('com.youdao.note:id/note_title').send_keys('testtitle')
            #内容
            #driver.find_element_by_class_name('android.widget.EditText').send_keys('testcontent')
            self.driver.find_element_by_xpath("//*[@resource-id='com.youdao.note:id/note_content']/android.widget.EditText").send_keys('testcontent')
            #完成
            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 (title=='testtitle'):
            print("新增笔记成功")
      else:
            print("新增笔记失败")
if __name__ == '__main__':
    addnoteboj=yd_addnote()
    # addnoteboj.test_addnote()
    # addnoteboj.check_addnote()

学掌门网校 发表于 2019-9-26 16:43:07

本帖最后由 博为峰网校 于 2019-9-26 16:56 编辑

1、我这里把你的代码全部运行了,没有报错,结果是http://www.atstudy.com/files/course/2019/07-17/103337178c05316406.png不知道你的问题是什么意思,没有太明白

学掌门网校 发表于 2019-9-26 16:43:37

1、你打开模拟器自己输入一下汉字,只能通过键盘点击,选择汉字才可以

2、但是这个键盘是有道云自己封装的,定位工具识别不了

3、所以无法针对汉字内容进行自动化

学掌门网校 发表于 2019-9-26 16:43:50

1、你打开模拟器自己输入一下汉字,只能通过键盘点击,选择汉字才可以

2、但是这个键盘是有道云自己封装的,定位工具识别不了

3、所以无法针对汉字内容进行自动化
页: [1]
查看完整版本: 有道云任务-修改笔记,我调试的时候在修改笔记的内容的时候,模拟器调试修改的字符...