欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

有道云app项目测试框架构建:框架内的新增,查询,修改笔记测试脚本

程序员文章站 2022-04-21 10:23:14
class edit_test(BaseTest): table=reader(r"\addnote1.csv") @ddt.data(*table) def test_case(self,row): self.driver.implicitly_wait(10) aa=WebDriverWait(self.driver,15).until(lambda x: x.find_element_by_id("com.youdao.note:id/btn_o...
import ddt
from func1.csvreader import reader
from test_case1.BaseTest import BaseTest
from selenium.webdriver.support.wait import WebDriverWait
@ddt.ddt
class edit_test(BaseTest):
    table=reader(r"\addnote1.csv")
    @ddt.data(*table)
    def test_case(self,row):
        self.driver.implicitly_wait(10)
        aa=WebDriverWait(self.driver,15).until(lambda x: x.find_element_by_id("com.youdao.note:id/btn_ok"))
        if aa:
            # 点击同意按钮
            self.driver.find_element_by_id("com.youdao.note:id/btn_ok").click()
            # 点击取消按钮
            self.driver.find_element_by_id("com.youdao.note:id/btn_cancel").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_icon").click()
            # 点击“ALLOW"按钮
            self.driver.find_element_by_id("com.android.packageinstaller:id/permission_allow_button").click()
            # 输入内容
            self.driver.find_element_by_xpath(
                "//*[@resource-id='com.youdao.note:id/note_content']/android.widget.EditText").send_keys(row[1])
            # 输入标题
            self.driver.find_element_by_id("com.youdao.note:id/note_title").send_keys(row[0])
            # 点击"完成"按钮
            self.driver.find_element_by_id("com.youdao.note:id/actionbar_complete_text").click()
            # 获取新增成功后的标题内容
            result = self.driver.find_element_by_id("com.youdao.note:id/title").text
            # 断言判断
            self.assertEqual(row[0],result)
            # 点击搜索按钮
            self.driver.find_element_by_id('com.youdao.note:id/search').click()
            # 输入搜索关键字
            self.driver.find_element_by_id('com.youdao.note:id/search_edit_view').send_keys(row[0])
            # 点击搜索按钮
            self.driver.find_element_by_id('com.youdao.note:id/action_btn').click()
            # 获取搜索后的标题内容
            result=self.driver.find_element_by_id("com.youdao.note:id/title").text
            # 断言判断
            self.assertEqual(row[0],result)
            # 选择要修改的笔记
            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(row[3])
            #修改标题
            self.driver.find_element_by_id("com.youdao.note:id/note_title").send_keys(row[2])
            # 点击完成
            self.driver.find_element_by_id("com.youdao.note:id/actionbar_complete_text").click()
            #获取修改后的标题
            result=self.driver.find_element_by_id('com.youdao.note:id/note_title').text
            #断言
            self.assertEqual(row[2],result)

本文地址:https://blog.csdn.net/zou75718/article/details/108718238