1. 參數(shù)化
- 根據(jù)傳入的數(shù)據(jù),對測試用例進行迭代調(diào)用,參數(shù)化是數(shù)據(jù)驅(qū)動的基礎
@pytest.mark.parametrize("參數(shù)名1","參數(shù)名2",...[(參數(shù)1,參數(shù)2),(參數(shù)3,參數(shù)4)])
2. 數(shù)據(jù)驅(qū)動
-
基于數(shù)據(jù)完成流程調(diào)度,通常數(shù)據(jù)來源于外部數(shù)據(jù)文件
3. yaml讀取文件
import yaml
yaml.save_load(open('fileName','r'))
def read_yaml_list(self,ele_name):
#讀取yaml列表數(shù)據(jù)
for data in self.data:
for key in data.keys():
if key == ele_name:
return data[ele_name]
def get_yaml_value(self,title,section,option):
'''
獲取yaml文件中指定section下指定的value
:param title: yaml的title
:param section: yaml下的section
:param option: key值
:return: key值對應的value
'''
eleloc_title_dict = self.data[title]
eleloc_dict = eleloc_title_dict[section]
eleloc_value = eleloc_dict[option]
return eleloc_value
def get_yaml_all_items(self, title):
'''
獲取yaml文件中指定title下所有的元素定位
:param title: yaml的title
:return: 返回指定yaml文件title下所有的元素定位
'''
eleloc_dict = self.data[title]
return eleloc_dict
def get_yaml_section_items(self, title, section):
'''
獲取yaml文件中指定section下所有的元素定位
:param title: yaml的title
:param section: title下指定的section
:return: 返回指定section下所有元素定位
'''
eleloc_title_dict = self.data[title]
eleloc_dict = eleloc_title_dict[section]
return eleloc_dict
4. yaml數(shù)據(jù)存儲
- ele_image_id: com.sudiyi.apps.launcher:id/image_logo