UI自动化测试框架2

测试步骤的数据驱动

ID = "id"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
NAME = "name"
TAG_NAME = "tag name"
CLASS_NAME = "class name"
CSS_SELECTOR = "css selector"

代码地址:

改造顺序:

步骤1

goto_market:
  - by: xpath
    locator: "//*[@resource-id='android:id/tabs']//*[@text='行情']"
    action: click

步骤2

search:
  - by: xpath
    locator: '//*[@resource-id="com.xueqiu.android:id/search_input_text"]'
    action: send
    value: alibaba
  - by: xpath
    locator: '//*[@text="BABA"]'
    action: click

步骤三

# 从文件中读取           
with open(path, encoding="utf-8") as f:
data: dict = yaml.safe_load(f)

步骤四

for step in steps:
element = None
if "by" in step.keys():
element = self.find(step["by"], step["locator"])

录屏

作业

写完数据驱动的封装

交作业:


注:没有用雪球app,用的是一个电商app,实现了:选择不同的商品类别–>选中一款商品进行商品展示–>加入购物车–>加数量–>购物车结算–>提交订单
page部分:page/shopping_mall
用例部分:test_case/shopping_mall

课后作业:https://github.com/pj1124/teststudy/tree/master/xueqiu

交作业

交作业

https://github.com/sweet-shine/HGWZ_TASK/tree/master/UIAutoFrame/second_task

关闭