Appium_测试步骤读取自外部文件:定制执行引擎

Posted jiguanghover

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Appium_测试步骤读取自外部文件:定制执行引擎相关的知识,希望对你有一定的参考价值。

 1 class TestCase:
 2     def __init__(self,path):
 3         file = open(path,"r")
 4         self.steps = yaml.safe_load(file)
 5         
 6     def run(self,driver:WebDriver):
 7         for step in self.steps:
 8             element = None
 9             if isinstance(step,dict):
10                 if "id" in step.keys():
11                     element = driver.find_element_by_id(step["id"])
12                 elif "xpath" in step.keys():
13                     element = driver.find_element_by_xpath(step["xpath"])
14                 else:
15                     print(step.keys())
16             if "input" in step.keys():
17                 element.send_keys(step["input"])
18             elif "get" in step.keys():
19                 element.get_attribute(step["get"])
20             else:
21                 element.click()

 

参考内容:

1. https://www.bilibili.com/video/av79004717?p=26

以上是关于Appium_测试步骤读取自外部文件:定制执行引擎的主要内容,如果未能解决你的问题,请参考以下文章

使用 Appium 执行 swipe() 时提到的“步骤”是啥

Appium学习实践结构优化

项目管理Maven系列- 创建项目POM文件依赖机制生命周期定制库外部依赖

Appium定义接口测试

Appium - monkey自定义脚本实践

使用 Tez 执行引擎将文件系统添加到 Hive