def login(self): objRepo = ObjectRepository() self.util = Utilities() self.config = self.util.readProperties("config.properties") browser = self.config["browserName"] timeout = int(self.config["timeout"]) self.browser = self.util.getBrowser(browser) self.url = "https://opensource-demo.orangehrmlive.com/" self.browser.implicitly_wait(timeout) print(">>> running setUp: login") self.browser.get(self.url) print("Launching the orangehrm ") print(self.browser.title) time.sleep(2) self.util.passValue( "id", objRepo.username_txt_id, "admin", self.browser) #byType, byValue, valueToPass, driver self.util.passValue("id", objRepo.password_txt_id, "admin123", self.browser) self.util.clickElement("id", objRepo.login_btn_id, self.browser) welcomeadmin = self.browser.find_element_by_id( "welcome").is_displayed() print("logged in is displayed : ", welcomeadmin) return self.browser
def setUp(self): util = Utilities() objRepo = ObjectRepository() print(">>> running setUp: login") self.browser.get(self.url) print("Launching the orangehrm ") print(self.browser.title) time.sleep(2) # Enhancement2 - using the object repository structure util.passValue("id", objRepo.username_txt_id, "admin", self.browser) #byType, byValue, valueToPass, driver util.passValue("id", objRepo.password_txt_id, "admin123", self.browser) util.clickElement("id", objRepo.login_btn_id, self.browser) # Enhancement 1 - created util class and using methods of it # util.passValue("id", "txtUsername", "admin", self.browser) #byType, byValue, valueToPass, driver # util.passValue("id", "txtPassword", "admin123", self.browser) # util.clickElement("id", "btnLogin", self.browser) # Initial line of code # self.browser.find_element_by_id("txtUsername").send_keys('admin') # self.browser.find_element_by_id("txtPassword").send_keys('admin123') # self.browser.find_element_by_id("btnLogin").click() welcomeadmin = self.browser.find_element_by_id( "welcome").is_displayed() print("logged in is displayed : ", welcomeadmin)
class Login: def Login(self): # global pwd # global newUsername self.util = Utilities() # self.config = self.util.readProperties("../Unittest_Example/config.properties") self.config = self.util.readProperties("config.properties") browser = self.config["browserName"] timeout = int(self.config["timeout"]) self.pwd = "Apple123" self.newUsername = "******" self.browser = self.util.getBrowser(browser) self.url = "https://opensource-demo.orangehrmlive.com/" self.user_url = "https://opensource-demo.orangehrmlive.com/index.php/admin/viewSystemUsers" self.browser.implicitly_wait(timeout) util = Utilities() objRepo = ObjectRepository() print(">>> running setUp: login") self.browser.get(self.url) print("Launching the orangehrm ") print(self.browser.title) time.sleep(2) # Enhancement2 - using the object repository structure util.passValue("id", objRepo.username_txt_id, "admin", self.browser) # byType, byValue, valueToPass, driver util.passValue("id", objRepo.password_txt_id, "admin123", self.browser) util.clickElement("id", objRepo.login_btn_id, self.browser) welcomeadmin = self.browser.find_element_by_id( "welcome").is_displayed() print("logged in is displayed : ", welcomeadmin) # open the User url return self.browser
def setUpClass(cls): global pwd global newUsername cls.util = Utilities() cls.config = cls.util.readProperties( "../Unittest_Example/config.properties") browser = cls.config["browserName"] timeout = int(cls.config["timeout"]) # cls.browser = webdriver.Chrome(executable_path="../drivers/chromedriver.exe") cls.browser = cls.util.getBrowser(browser) cls.url = "https://opensource-demo.orangehrmlive.com/" cls.user_url = "https://opensource-demo.orangehrmlive.com/index.php/admin/viewSystemUsers" cls.browser.implicitly_wait(timeout)
def tearDownClass(cls): u = Utilities() print("quiting the driver") u.closeBrowser(cls.browser)
def tearDownClass(self): u = Utilities() print("Quiting the browser") u.closeBrowser(self.browser)
import unittest from Unittest_Example.NewTC1_SearchUser import NewTC1_SearchUser from Unittest_Example.NewTC2_AddUser import NewTC2_AddUser from Unittest_Example.NewTC3_EditUser import NewTC3_EditUser from Unittest_Example.NewTC4_DeleteUser import NewTC4_DeleteUser from Unittest_Example.Utilities import Utilities NewTC1 = unittest.TestLoader().loadTestsFromTestCase(NewTC1_SearchUser) NewTC2 = unittest.TestLoader().loadTestsFromTestCase(NewTC2_AddUser) NewTC3 = unittest.TestLoader().loadTestsFromTestCase(NewTC3_EditUser) NewTC4 = unittest.TestLoader().loadTestsFromTestCase(NewTC4_DeleteUser) smokeTestSuite = unittest.TestSuite([NewTC1, NewTC2, NewTC3, NewTC4]) RegressionTestSuite = unittest.TestSuite([NewTC1, NewTC2, NewTC3]) IntegrationTestSuite = unittest.TestSuite([NewTC2, NewTC2]) u = Utilities() config = u.readProperties("config.properties") suiteName = config["suiteName"] if suiteName == "SMOKE": unittest.TextTestRunner().run(smokeTestSuite) elif suiteName == "REGRESSION": unittest.TextTestRunner().run(RegressionTestSuite) elif suiteName == "INTEGRATION": unittest.TextTestRunner().run(IntegrationTestSuite)