zoukankan      html  css  js  c++  java
  • UI自动化测试常用操作函数(3)

    import os
    def get_testinfo(conf,index,dir):
    import xlrd
    workbook = xlrd.open_workbook(dir+conf[index]['info_path'])
    worksheet = workbook.sheet_by_name(conf[index]['sheetname'])
    testinfo = []
    for i in range(conf[0]['start_row'],conf[index]['end_row']):
    testdata = worksheet.cell(i,conf[index]['testdata_col']).value
    expect = worksheet.cell(i,conf[index]['expect_col']).value
    tmp = testdata.split(' ')
    tup = {}
    for j in tmp:
    tup[j.split('=')[0]] = j.split('=')[1]
    tup['expect'] = expect
    testinfo.append(tup)
    return testinfo

    def get_json(path):
    import json
    try:
    with open(path,encoding='utf-8') as f:
    contents = json.load(f)
    except Exception as e:
    print(e)
    finally:
    f.close()
    return contents

    root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    path = root_dir+'\demo1130\testdata.json'
    data = get_json(path)
    i=0
    print(get_testinfo(data,i,root_dir))

    运行结果:

    方法解释:在UI自动化中,采用分层思想,将每个模块需要调用的参数写在json中。如login:

     具体用例写在excel中:

     先通过get_json函数读取参数,然后将参数传入get_testinfo函数,读取对应的用例数据,最后可将用例数据传到具体模块的操作函数中。

    每天进步一点点!
  • 相关阅读:
    系统综合实践第一次实践作业
    个人作业——软件工程实践总结作业
    个人作业——软件评测
    软件工程实践第五次作业
    Structured Multimodal Attentions for TextVQA
    文字版三国杀开发
    OO Unit 4 Summary
    TextCaps竞赛总结
    Multi-Source Pointer Network
    Pointer Generator Network
  • 原文地址:https://www.cnblogs.com/qianjunjun/p/14142549.html
Copyright © 2011-2022 走看看