python - How to control test case run through an excel sheet? -
my question design problem. using python + selenium automation. pyunit unit framework used. have sheet in excel have 2 columns- testcaseid , run. testcaseid have testcase id in , run have either y or n signifying whether test case should runnable or not. trying read particular test case id sheet , see have it's run value, y or n. if y, test case executed unit framework else not run.
here excerpt of test case have written:
`class test_id_94017(unittest.testcase):
ex = excel() def setup(self): self.ex.setupasheetinexcel('select_test_cases_to_run') if self.ex.gettestcaserunstatusfromexcel("94017") == "y": self.driver = browser().createbrowserdriver() self.driver.maximize_window() self.driver.implicitly_wait(15) self.ex.setupasheetinexcel('login') else: return def test_ccpd_regression001_per_custom_check(self): //do
the definition gettestcaserunstatusfromexcel(testcaseid) method is:
`def gettestcaserunstatusfromexcel(self, testcaseid):
i=1 while self.worksheet.cell_value(i,0).value != testcaseid: i+=1 return self.worksheet.cell_value(i,1).value
here problems facing:
how should give condition in existing code y, test case executes? should give if condition in setup method test case class have mentioned in code above?
is way in trying iterate on rows in column (of excel sheet) correct until find testcase id , corresponding run value (y or n)?
please help!
i implemented similar design selenium+testng suite. after reading execution flags excel, create testng.xml dynamically , run same xml. testng provides features xml created , executed dynamically. not sure if have similar in pyunit. hope gives ideas.
Comments
Post a Comment