标签:传值 取出 方式 查看 简单 压缩 类型 code 图片
# 简单的case_yaml模板
- Descripton: 进入搜索页面
Methods: id
Value: ivSearch
Action: click
- Descripton: 搜索测试数据
Methods: id
Value: etSearch
Action: send_keys
data: 测试
- Descripton: 获取搜索值
Methods: id
Value: tvSearchResult
Action: text
class TestCaseTemplate:
def __init__(self, path):
with open(path, ‘r‘, encoding="utf-8") as file:
self.steps = yaml.safe_load(file)
def method(self, driver: WebDriver, method, value):
ele = None
if method == ‘id‘:
ele = driver.find_element_by_id(value)
elif method ==‘xpath‘:
ele = driver.find_element_by_xpath(value)
elif method == ‘accessibility‘:
ele = driver.find_element_by_accessibility_id(value)
else:
return ‘No element‘
return ele
def run(self, driver: WebDriver):
for step in self.steps:
elemet = None
if isinstance(step, dict):
if ‘Methods‘ in step.keys() and ‘Value‘ in step.keys():
elemet = self.method(driver, step[‘Methods‘], step[‘Value‘])
else:
print(step.keys())
if ‘Action‘ in step.keys():
if ‘click‘ in step[‘Action‘]:
elemet.click()
elif ‘send_keys‘ in step[‘Action‘]:
if ‘data‘ in step.keys():
elemet.send_keys(step[‘data‘])
else:
print(‘没有输入的测试数据‘)
elif ‘text‘ in step[‘Action‘]:
data = elemet.text
print(data)
https://github.com/wangxiao9/appium_demo.git
标签:传值 取出 方式 查看 简单 压缩 类型 code 图片
原文地址:https://www.cnblogs.com/muzii/p/13460306.html