首页 > 移动平台 > 详细

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

时间:2020-03-08 14:04:25      阅读:103      评论:0      收藏:0      [点我收藏+]
testcase.yaml:
- id: home_search
- id: search_input_text
  input: alibaba
- id: name
- id: current_price
  get: text

class TestDemo:
    def test_search_from_testcase(self):
        TestCase("testcase.yaml").run(self.driver)

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"])
			else:
				element.click()
			if "get" in step.keys():
				text = element.get_attribute(step["get"])
				print(text)

  

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

原文:https://www.cnblogs.com/jiguanghover/p/12441918.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!