I\'m new with python, and I\'m trying to create my own test suite.
The main pourpose is to execute the same test on different browser, that\'s why I used the variabl
maybe isn't a Pythonic way, but I found a solution:
class Test01(unittest.TestCase):
def test_login(self):
self.page = "https://myWebPageAddress"
self.username = "userName"
self.password = "Password"
self.browser_label = ['firefox', 'chrome', 'ie']
for index in range(len(self.browser_label)):
self.browser_name = self.browser_label[index]
if self.browser_name == 'firefox':
logger.debug("Opening [" + self.browser_name + "] ...")
self.driver = webdriver.Firefox()
if self.browser_name == 'chrome':
logger.debug("Opening [" + self.browser_name + "] ...")
self.driver = webdriver.Chrome()
if self.browser_name == 'ie':
logger.debug("Opening [" + self.browser_name + "] ...")
self.driver = webdriver.Ie()
try:
logger.info("Test_01::Case_01::Login OK")
Test01.case_01(self)
except BaseException as e:
logger.fatal(e.value)
logger.info("End")
self.driver.close()
def case_01(self):
....
....
I hope that's could be helpfull for someone.