老师我是自动化的新手当前基本按照教程里面的PO模型写的代码测试的是自己的app。python3版本。
用例是:点击笔记标题 弹出dialog会话框 输入框输入标题名 点击确认
PO模型各层相关的代码
page层
def get_note_name_element(self):
'''
获取笔记标题元素
:return:
'''
return self.get_local_by.get_element('note_name', 'note_element')
def get_note_edit_name(self):
'''
点击note_name后弹出的对话框中 输入框元素
:return:
'''
return self.get_local_by.get_element('edit_name', 'note_element')
handle层
def click_note_name(self):
'''
点击标题 区域
:return:
'''
self.note_page.get_note_name_element().click()
def edit_note_name(self, new_note_name):
'''
编辑笔记的标题
:param new_note_name:
:return:
'''
self.note_page.get_note_edit_name().send_keys(new_note_name)
business层
def edit_pass(self):
'''
编辑标题成功
:return:
'''
self.note_handle.click_note_name()
# print("已经点击标题区域了。。。。")
self.note_handle.edit_note_name(u"测试标题")
self.note_handle.edit_confirm()
self.note_handle.save_and_back()
case层
import unittest
import HTMLTestReportCN
from business.note_business import NoteBusiness
import time
class NoteCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
print("this is set up class.")
@classmethod
def tearDownClass(cls):
print("this is tear down class.")
def setUp(self):
# print("开始初始化driver.")
self.note_business = NoteBusiness()
def tearDown(self):
print("this is tear down.")
def test001(self):
'''
修改笔记标题成功
:return:
'''
self.note_business.edit_pass()
用例执行时business层的第一句点击操作执行成功了但是第二句self.note_handle.edit_note_name(u"测试标题")找不到元素是NoneType报错如下
Traceback (most recent call last):
File “D:/EPD_xbdn_Test/TestProjects/UIAutomatedProject/case/note_case.py”, line 31, in test001
self.note_business.edit_pass()
File “D:EPD_xbdn_TestTestProjectsUIAutomatedProjectusiness
ote_business.py”, line 28, in edit_pass
self.note_handle.edit_note_name(u"测试标题")
File “D:EPD_xbdn_TestTestProjectsUIAutomatedProjecthandle
ote_handle.py”, line 23, in edit_note_name
self.note_page.get_note_edit_name().send_keys(new_note_name)
AttributeError: ‘NoneType’ object has no attribute ‘send_keys’
现在我的用例执行卡在这个步骤了其他的用例也是同类的报错。希望老师能给我解答下原因