Ejemplo n.º 1
0
    def test_add_employee(self):
        # Login action
        login_page = LoginPage(self.driver)
        login_page.set_username(self.username)
        login_page.set_password(self.password)
        login_page.click_login_btn()

        # Click on PIM link in main menu
        main_menu = MainMenu(self.driver)
        main_menu.click_pim()
        time.sleep(0.5)  # need to use sleep due to issue on the web page

        # Click on Add Employee element in submenu
        pim_menu = PimMenu(self.driver)
        pim_menu.click_add_employee()

        # Add Employee h1 verification
        add_employee_page = AddEmployee(self.driver)
        self.assertEqual('Add Employee', add_employee_page.is_header_visible())

        # Adding employee
        add_employee_page.set_first_name(self.first_name)
        add_employee_page.set_middle_name(self.middle_name)
        add_employee_page.set_last_name(self.last_name)
        add_employee_page.set_employee_id(self.employee_id)
        add_employee_page.click_save()
        time.sleep(2)

        # Check on employee details if user h1 is equal to full name (in this case to combined: first name, middle name, last name)
        view_employee_page = ViewEmployee(self.driver)
        self.assertEqual(
            f'{self.first_name} {self.middle_name} {self.last_name}',
            view_employee_page.user_header_visible())
Ejemplo n.º 2
0
class Test_01_Login:
    base_url = ReadConfig.getApplicationURL()
    username = ReadConfig.getUserName()
    password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    @pytest.mark.sanity
    def test_homepage(self, setup):
        self.logger.info(
            "********************** Test_01_Login **********************")
        self.logger.info(
            "********************** Verify Home Page Title **********************"
        )
        self.driver = setup
        self.driver.get(self.base_url)
        actual_title = self.driver.title
        if actual_title == "Your store. Login":
            assert True
            self.driver.close()
            self.logger.info(
                "********************** Home Page Title is passed **********************"
            )
        else:
            self.driver.save_screenshot(".\\screenshots\\test_homepage2.png")
            self.driver.close()
            self.logger.error(
                "********************** Home Page Title is failed **********************"
            )
            assert False

    # @pytest.mark.sanity
    @pytest.mark.regression
    def test_login(self, setup):
        self.logger.info(
            "********************** Verifying Login Test**********************"
        )
        self.driver = setup
        self.driver.get(self.base_url)
        self.lp = LoginPage(self.driver)
        self.lp.setuserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickonlogin()
        actual_title = self.driver.title
        if actual_title == "Dashboard / nopCommerce administration":
            assert True
            self.lp.clickonlogout()
            time.sleep(2)
            self.driver.close()
            self.logger.info(
                "********************** Test Login passed **********************"
            )
        else:
            self.driver.save_screenshot(".\\screenshots\\test_login1.png")
            self.driver.close()
            self.logger.error(
                "********************** Test Login Failed **********************"
            )
            assert False
Ejemplo n.º 3
0
 def test_correct_login(self):
     login_page = LoginPage(self.driver)
     login_page.set_username(self.username)
     login_page.set_password(self.password)
     login_page.click_login_btn()
     dashboard_page = DashboardPage(self.driver)
     self.assertEqual('Dashboard', dashboard_page.check_header())
     self.driver.save_screenshot(f'../Screenshots/test_correct_login{self.time_stamp}.png')
    def test_addCustomer(self, setup):
        self.logger.info("*********************** Test_03_add_customer Started *******************")
        self.driver = setup
        self.driver.get(self.base_url)
        self.driver.maximize_window()

        self.lp = LoginPage(self.driver)
        self.lp.setuserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickonlogin()
        self.logger.info("**************** Logged In Successfully *****************")
        self.logger.info("************ Started Add Customer Test **************")

        self.addcust = AddCust(self.driver)
        self.addcust.clickOnCustomers()
        self.addcust.clickOnCustomersMenu()
        self.addcust.clickOnAddNew()

        self.email = random_generator() + "@gmail.com"
        self.addcust.setEmail(self.email)
        self.addcust.setPassword("test111")
        self.addcust.setFirstName("Ajay")
        self.addcust.setLastname("Thakur")
        self.addcust.selectGender("Male")
        self.addcust.setDOB("01/05/1989")
        self.addcust.setCompanyName("AutomationQA")
        self.addcust.setAdminComment("This is for testing ..")
        self.addcust.setCustomerRoles("Vendors")
        self.addcust.selectManagerOfVendor("Vendor 1")
        self.addcust.clickOnSavebutton()

        self.logger.info("************  Saving Customer Info **************")
        self.logger.info("*************  Add Customer Validation Started ***************")

        self.msg = self.driver.find_element_by_tag_name("body").text
        print(self.msg)

        if 'The new customer has been added successfully.' in self.msg:
            assert True
            self.logger.info("************* Add Customer test Passed ****************")
        else:
            self.driver.save_screenshot(".\\screenshots\\test_addCustomer.png")
            self.logger.error("**************** Add Customer Failed *****************")
            assert True

        self.driver.close()
        self.logger.info("*************** Ending Test_03_add_customer test ****************")
    def test_b_login_invalid(self):
        driver = self.driver
        self.driver.get(Constants.appURL)

        loginpage = LoginPage(driver)
        #loginpage.login(Constants.userName,Constants.passWord)
        #loginpage.login("*****@*****.**",123456)
        excelReader = ExcelReader(Constants.inputFile, Constants.sheet1)
        loginpage.enter_username(
            excelReader.getUserName(self.LoginInValidDataRow))
        loginpage.enter_password(
            excelReader.getPassword(self.LoginInValidDataRow))
        loginpage.click_login()
        time.sleep(2)
    def test_SearchCustbyName(self, setup):
        self.logger.info(
            self.logger.info(
                "********************** Test_004 Search Cust By Name **********************"
            ))
        self.driver = setup
        self.driver.get(self.base_url)
        self.driver.maximize_window()
        self.lp = LoginPage(self.driver)
        self.lp.setuserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickonlogin()

        self.addCust = AddCust(self.driver)
        self.addCust.clickOnCustomers()
        self.addCust.clickOnCustomersMenu()

        srhCust = SearchCustomer(self.driver)
        srhCust.setFirstName("Steve")
        srhCust.setLastName("Gates")
        srhCust.clickOnSearchButton()
        time.sleep(5)
        status = srhCust.searchByName("Steve Gates")

        if status == True:
            assert True
            self.logger.info(
                "************** Test 004 Search Cust By Name Passed ********************"
            )
        else:
            self.logger.error(
                "************** Test 004 Search Cust By Name Failed ********************"
            )
            assert False
        self.driver.close()
        self.logger.info(
            "************** Test 004 Search Cust By Name Finished ********************"
        )
    def test_a_login_valid(self):
        driver = self.driver
        #self.log.info("App URL fetched.")
        self.driver.get(Constants.appURL)

        loginpage = LoginPage(driver)
        #loginpage.login(Constants.userName,Constants.passWord)
        #loginpage.login("*****@*****.**",123456)
        #self.log.info("Entered Username & Password.")
        excelReader = ExcelReader(Constants.inputFile, Constants.sheet1)
        loginpage.enter_username(
            excelReader.getUserName(self.LoginValidDataRow))
        loginpage.enter_password(
            excelReader.getPassword(self.LoginValidDataRow))
        loginpage.click_login()
        #self.log.info("Loggin Sucuessfully")
        time.sleep(2)
Ejemplo n.º 8
0
class Test_004SearchCustByEmail:
    base_url = ReadConfig.getApplicationURL()
    username = ReadConfig.getUserName()
    password = ReadConfig.getPassword()

    logger=LogGen.loggen()


    @pytest.mark.regresssion
    def test_searchCUstomer(self, setup):
        self.logger.info("****************** Test004 Search Customer By Email ***********************")
        self.logger.info("********************** Verify Home Page Title **********************")
        self.driver = setup
        self.driver.get(self.base_url)
        self.driver.maximize_window()
        self.lp = LoginPage(self.driver)
        self.lp.setuserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickonlogin()

        self.addCust = AddCust(self.driver)
        self.addCust.clickOnCustomers()
        self.addCust.clickOnCustomersMenu()
        self.logger.info("*************** Searching Customer By Email ID ****************")
        searchCust = SearchCustomer(self.driver)
        searchCust.setEmail("*****@*****.**")
        searchCust.clickOnSearchButton()
        time.sleep(5)
        self.status = searchCust.searchCustByEmail("*****@*****.**")
        if self.status == True:
            assert True
            self.logger.info("***************** Search Cust By Email Test Passed ******************")
        else:
            self.logger.error("***************** Search Cust By Email Test Failed ******************")
            assert False
        self.driver.close()

        self.logger.info("***************** Test 004 Search Cust By Email Test Finished ******************")
    def test_ddt_login_002(self, setup):
        self.logger.info(
            "********************** test_ddt_login_002 ***********************"
        )
        self.logger.info(
            "********************** Verifying DDT Login Test **********************"
        )
        self.driver = setup
        self.driver.get(self.base_url)

        self.lp = LoginPage(self.driver)
        self.row = XLUtily.getRowCount(self.path, 'Sheet2')
        print("No of ROws in a sheet : ", self.row)

        lst_status = []
        for r in range(2, self.row + 1):

            self.user = XLUtily.readData(self.path, 'Sheet2', r, 1)
            self.password = XLUtily.readData(self.path, 'Sheet2', r, 2)
            self.exp = XLUtily.readData(self.path, 'Sheet2', r, 3)

            self.lp.setuserName(self.user)
            self.lp.setPassword(self.password)
            self.lp.clickonlogin()
            time.sleep(5)

            act_title = self.driver.title
            exp_title = "Dashboard / nopCommerce administration"

            if act_title == exp_title:
                if self.exp == "Pass":
                    self.logger.info(
                        "************* Test Passed **************")
                    self.lp.clickonlogout()
                    lst_status.append('Pass')
                elif self.exp == "Fail":
                    self.logger.error(
                        "************* Test Failed **************")
                    self.lp.clickonlogout()
                    lst_status.append('Fail')
            elif act_title != exp_title:
                if self.exp == "Pass":
                    self.logger.error(
                        "************* Test Failed **************")
                    lst_status.append('Fail')
                elif self.exp == "Fail":
                    self.logger.info(
                        "************* Test Passed **************")
                    lst_status.append('Pass')
        print("Status : ", lst_status)
        if 'Fail' not in lst_status:
            self.logger.info(
                "************* Login Test DDT is Passed **************")
            self.driver.close()
            assert True
        else:
            self.logger.error(
                "************* Login Test DDT is Failed **************")
            self.driver.close()
            assert False
        self.logger.info("************* End Of Login DDT Test **************")
        self.logger.info(
            "************* test_ddt_login_002 Completed **************")
class Test_02_Login_DTT:
    base_url = ReadConfig.getApplicationURL()
    path = r"E:\SeleniumFramework\HybridFramework\PytestProject\testData\LoginTestData.xlsx"
    logger = LogGen.loggen()

    @pytest.mark.sanity
    @pytest.mark.regresssion
    # @pytest.mark.ajay
    def test_ddt_login_002(self, setup):
        self.logger.info(
            "********************** test_ddt_login_002 ***********************"
        )
        self.logger.info(
            "********************** Verifying DDT Login Test **********************"
        )
        self.driver = setup
        self.driver.get(self.base_url)

        self.lp = LoginPage(self.driver)
        self.row = XLUtily.getRowCount(self.path, 'Sheet2')
        print("No of ROws in a sheet : ", self.row)

        lst_status = []
        for r in range(2, self.row + 1):

            self.user = XLUtily.readData(self.path, 'Sheet2', r, 1)
            self.password = XLUtily.readData(self.path, 'Sheet2', r, 2)
            self.exp = XLUtily.readData(self.path, 'Sheet2', r, 3)

            self.lp.setuserName(self.user)
            self.lp.setPassword(self.password)
            self.lp.clickonlogin()
            time.sleep(5)

            act_title = self.driver.title
            exp_title = "Dashboard / nopCommerce administration"

            if act_title == exp_title:
                if self.exp == "Pass":
                    self.logger.info(
                        "************* Test Passed **************")
                    self.lp.clickonlogout()
                    lst_status.append('Pass')
                elif self.exp == "Fail":
                    self.logger.error(
                        "************* Test Failed **************")
                    self.lp.clickonlogout()
                    lst_status.append('Fail')
            elif act_title != exp_title:
                if self.exp == "Pass":
                    self.logger.error(
                        "************* Test Failed **************")
                    lst_status.append('Fail')
                elif self.exp == "Fail":
                    self.logger.info(
                        "************* Test Passed **************")
                    lst_status.append('Pass')
        print("Status : ", lst_status)
        if 'Fail' not in lst_status:
            self.logger.info(
                "************* Login Test DDT is Passed **************")
            self.driver.close()
            assert True
        else:
            self.logger.error(
                "************* Login Test DDT is Failed **************")
            self.driver.close()
            assert False
        self.logger.info("************* End Of Login DDT Test **************")
        self.logger.info(
            "************* test_ddt_login_002 Completed **************")
Ejemplo n.º 11
0
class TestLogin(unittest.TestCase):
    def setUp(self):
        self.logger = Log()
        self.logger.log_info('「Login Test Start:')
        url = 'http://10.10.15.153'
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.lp = LoginPage(self.driver, url)
        time.sleep(3)

    def tearDown(self):
        self.driver.quit()
        self.logger.log_info('_Login Test End」')

    # 登录成功
    def test_1_login_success(self):
        self.lp.login('system', '123456')
        time.sleep(3)
        try:
            msg = self.driver.find_element_by_xpath(
                '//*[@class="gd-topbar-tool-text"]').text
            self.assertEquals('system', msg)
            self.logger.log_info('Test Case "test_1_login_success" Passed !')
        except Exception as e:
            self.logger.log_error(
                'Test Case "test_4_login_fail" Failed ! \n{0}'.format(e))
            raise e

    # 无用户名登录
    def test_2_login_no_username(self):
        self.lp.login('', '123456')
        time.sleep(3)
        try:
            msg = self.driver.find_element_by_xpath(
                '//*[@class="gd-login-submit-text"]').text
            self.assertEquals('登 录', msg)
            self.logger.log_info(
                'Test Case "test_2_login_no_username" Passed !')
        except Exception as e:
            self.logger.log_error(
                'Test Case "test_4_login_fail" Failed ! \n{0}'.format(e))
            raise e

    # 无密码登录
    def test_3_login_no_passwd(self):
        self.lp.login('system', '')
        time.sleep(3)
        msg = self.driver.find_element_by_xpath(
            '//*[@class="gd-login-submit-text"]').text
        try:
            msg = self.driver.find_element_by_xpath(
                '//*[@class="gd-login-submit-text"]').text
            self.assertEquals('登 录', msg)
            self.logger.log_info('Test Case "test_3_login_no_passwd" Passed !')
        except Exception as e:
            self.logger.log_error(
                'Test Case "test_4_login_fail" Failed ! \n{0}'.format(e))
            raise e

    # 用户名/密码错误
    def test_4_login_fail(self):
        self.lp.login('system', '1234567890')
        time.sleep(3)
        try:
            msg = self.driver.find_element_by_xpath(
                '//*[@class="gd-login-msg"]').text
            self.assertEquals('用户名或密码错误', msg)
            self.logger.log_info('Test Case "test_4_login_fail" Passed !')
        except Exception as e:
            self.logger.log_error(
                'Test Case "test_4_login_fail" Failed ! \n{0}'.format(e))
            raise e
Ejemplo n.º 12
0
 def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.driver.get("https://www.91testing.net/login")
     cls.driver.maximize_window()
     cls.po = LoginPage(cls.driver)