chunianyo 2020-03-08
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()
参考内容: