话不多说直接上代码
# encoding:utf-8
from selenium import webdriver
import unittest
import xlwt
import xlrd
import time
from xlutils.copy import copy
from selenium.webdriver.common.by import By
class Denglu(unittest.TestCase):
def setUp(self):
self.driver=webdriver.Firefox()
self.baseurl="http://localhost:8000/phpwind85"
def testGetExcel(self,excelfile):
"""
该函数主要是获取需要读取数据的excel,如果找到就返回该excel,如果找不到给出提示信息
"""
try:
data=xlrd.open_workbook(excelfile)#获取通过excel路径工作表
table=data.sheets()[0]#制定需要操作的excel的sheet
return table#返回需要操作的excel的sheet
except:
return False
def testGetRows(self):
"""
该方法主要是得到要读取数据的excel的行
"""
table=self.testGetExcel("E:\\wwg\\dengludata.xls")
if table:
rows=table.nrows