首页 > 移动平台 > 详细

6-3-3ios自动化-数据驱动

时间:2018-09-18 21:49:46      阅读:188      评论:0      收藏:0      [点我收藏+]

https://testerhome.com/topics/14247

#!/usr/bin/env python3
# coding:utf-8
from appium import webdriver
import time,selenium,openpyxl,unittest

class testCheat(unittest.TestCase):
    def setUp(self):
        self.wb=openpyxl.load_workbook("ms.xlsx",data_only=True)
        self.wb.guess_types=True
        self.sh=self.wb[‘工作表 1‘]
        self.caps={}
        self.caps[‘bundleId‘]=‘com.taobaobj.moneyshield‘
        self.caps[‘newCommandTimeout‘]=600
        self.driver=webdriver.Remote("http://192.168.43.86:8100/wd/hub",self.caps)
        time.sleep(5)

    def find_element(self,xpath,timeout=30):
        deadline=time.time()+timeout
        while time.time() < deadline:
            try:
                el=self.driver.find_element_by_xpath(xpath)
                return el
            except Exception as e:
                time.sleep(0.5)
        raise RuntimeError("Element not found ")

    def test_ch(self):
        for row in self.sh.rows:
            if row[3].value not in [‘yes‘,]:
                continue
            print(row[0].value,row[1].value)
            op=row[0].value
            xpath=row[1].value
            if op ==‘click‘:
                self.find_element(xpath).click()
            if op == ‘assert‘:
                self.find_element(xpath)
            if op==‘send_keys‘:
                self.find_element(xpath).send_keys(row[4].value)

    def tearDown(self):
        self.driver.quit()

if __name__==‘__main__‘:
    unittest.main()

excel表格
技术分享图片
技术分享图片

6-3-3ios自动化-数据驱动

原文:https://www.cnblogs.com/csj2018/p/9671269.html

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