码迷,mamicode.com
首页 > 移动开发 > 详细

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

时间:2018-09-18 22:39:51      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:obj   技术   error   tao   pat   width   ror   xls   pes   

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自动化-数据驱动

标签:obj   技术   error   tao   pat   width   ror   xls   pes   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!