Here is my code. I wrote script which can test multiple test cases. This scripts throws an exception when an error comes however i want that it keeps the count of errors and their descriptions and log after test execution whether it is success or failed. More important is should run complete test script in any how.
from selenium import webdriver
from generic_functions.FindElement import HandyWrappers
from generic_functions.takescreenshots import Screenshot
from generic_functions.error_handle import CatchExceptions
import os
import time
import unittest
class TestEnrollment(unittest.TestCase):
driverLocation =
"C:\\Users\\Sales\\Desktop\\Automation\\Trendz\\libs\\chromedriver.exe"
os.environ["webdriver.chrome.driver"] = driverLocation
driver = webdriver.Chrome(driverLocation)
driver.maximize_window()
driver.implicitly_wait(10)
def test_login(self):
try:
baseURL = "https://portal.ABCD.com"
driver = self.driver
driver.get(baseURL)
hw = HandyWrappers(driver)
username = hw.getElement(".//form[@id='login-form']/fieldset/section[1]/label[2]/input[@name='email']",
locatorType="xpath")
username.send_keys("ABCD@live.com")
time.sleep(2)
password = hw.getElement(".//form[@id='login-form']/fieldset/section[2]/label[2]/input[@name='password']",
locatorType="xpath")
password.send_keys("ABCD09")
signIn = hw.getElement(".//form[@id='login-form']/footer/button[contains(text(),'Sign in')]",
locatorType="xpath")
signIn.click()
self.assertTrue(driver.find_element_by_xpath(".//header[@id='header']/section/div/div[@id='logout']/span/a12"), "Sign Out")
except Exception as err:
raise err
def test_menu_enr(self):
driver = self.driver
hw = HandyWrappers(driver)
find_enrollment = hw.getElement(".//aside[@id='left-panel']/nav/ul[14]/li/a/span", locatorType="xpath")
find_enrollment.click()
if __name__ == '__main__':
unittest.main()