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

class TestCase:
    def __init__(self,path):
        file = open(path,"r")
        self.steps = yaml.safe_load(file)
        
    def run(self,driver:WebDriver):
        for step in self.steps:
            element = None
            if isinstance(step,dict):
                if "id" in step.keys():
                    element = driver.find_element_by_id(step["id"])
                elif "xpath" in step.keys():
                    element = driver.find_element_by_xpath(step["xpath"])
                else:
                    print(step.keys())
            if "input" in step.keys():
                element.send_keys(step["input"])
            elif "get" in step.keys():
                element.get_attribute(step["get"])
            else:
                element.click()

参考内容:

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

相关推荐