Exemplo n.º 1
0
class TestLoginDDT_001:

    baseURL=ReadConfig.get_base_URL()
    logger=LogGen.log_gen()
    Datapath="./testdata/TestDataManagerLogin.xlsx"

    def test_login_ddt(self,setup):
        self.logger.info("****** TestLoginDDT_001 started ******")
        self.logger.info("****** verifying login ddt test ******")
        self.driver=setup
        self.driver.get(self.baseURL)

        self.lp=LoginPage(self.driver)
        self.rows=XLUties.get_row_count(self.Datapath,"Sheet1")
        print("Number of rows in Excel Data ",self.rows)

        lst_status=[]
        for r in range(2,self.rows+1):
            self.username=XLUties.read_data(self.Datapath,"Sheet1",r,1)
            self.password=XLUties.read_data(self.Datapath,"Sheet1",r,2)
            self.exp=XLUties.read_data(self.Datapath, "Sheet1",r,3)

            self.lp.set_user_id(self.username)
            self.lp.set_password(self.password)
            self.lp.click_on_login()
            actual_title=self.driver.title
            expected_title="Guru99 Bank Manager HomePage"
            if actual_title==expected_title:
                if self.exp=="Pass":
                    self.logger.info("------Passed------")
                    self.lp.click_on_logout()
                    self.driver.switch_to.alert.accept()
                    lst_status.append("Pass")
                elif self.exp=="Fail":
                    self.logger.info("------Failed------")
                    self.lp.click_on_logout()
                    time.sleep(5)
                    self.driver.switch_to.alertaccept()
                    lst_status.append("Fail")
            elif actual_title!=expected_title:
                if self.exp=="Pass":
                    self.logger.info("------Failed------")
                    lst_status.append("Fail")
                elif self.exp=="Fail":
                    self.logger.info("------Passed------")
                    lst_status.append("Pass")
        if "Fail" not in lst_status:
            self.logger.info("****** TestLoginDDT_001 Passed ******")
            self.driver.close()
            assert True
        else:
            self.logger.info("****** TestLoginDDT_001 Failed ******")
            self.driver.close()
            assert False
        self.logger.info("****** End of login DDT test ******")
        self.logger.info("**************** complete test login DDT ********************")
Exemplo n.º 2
0
class Test002LoginTestDDT:
    logger = Logger.get_logger()

    @pytest.mark.regression
    @pytest.mark.parametrize("user, pwd, expected", excel_utility.load_excel_data(ConfigParser.get_test_data_file_path(), 'login_data_sheet'))
    def test_login_ddt(self,setup, user, pwd, expected):
        self.logger.info("**************" + Test002LoginTestDDT.__name__ + "*************")
        self.logger.info("************** Verify Home Page title *************")
        self.login_page = LoginPage(setup)

        self.logger.info(f"Username : {user}")
        self.logger.info(f"password : {pwd}")
        self.logger.info(f"expected : {expected}")
        status_list = list()
        self.login_page.set_username(user)
        self.login_page.set_password(pwd)
        self.login_page.click_login()
        time.sleep(5)
        title = self.login_page.get_login_page_title()
        exp_title = "Dashboard / nopCommerce administration"
        if title == exp_title:
            if expected == 'pass':
                self.logger.info("*********passed***********")
                self.login_page.click_logout()
                status_list.append("pass")
            elif expected == 'fail':
                self.logger.info("*******failed*********")
                self.login_page.click_logout()
                status_list.append("fail")
        elif title != exp_title:
            if expected == 'fail':
                self.logger.info("*********passed***********")
                status_list.append("pass")
            elif expected == 'pass':
                self.logger.info("*********failed***********")
                status_list.append("fail")
        if 'fail' not in status_list:
            self.logger.info("********* Login DDT is passed***********")
            assert True
        else:
            self.logger.info("********* Login DDT is failed***********")
            assert False

        self.logger.info("************** Completed " + Test002LoginTestDDT.__name__ + "*************")
Exemplo n.º 3
0
class Test_Login_001:

    base_url = ReadConfig.get_base_URL()
    user_name = ReadConfig.get_user_name()
    password = ReadConfig.get_password()
    log = LogGen.log_gen()

    @pytest.mark.smoke
    def test_open_browser(self, setup):
        self.log.info("------Open browser test------")
        self.driver = setup
        self.driver.get(self.base_url)
        actual_url = self.driver.current_url
        if actual_url == "http://demo.guru99.com/V4/":
            assert True
            self.log.info("------ open browser test passed ------")
            self.driver.close()
        else:
            self.driver.save_screenshot("../screenshots/" +
                                        'test_homepage_title.png')
            self.driver.close()
            self.log.error("------ open browser test failed ------")
            assert False

    @pytest.mark.smoke
    def test_home_page_title(self, setup):
        self.log.info("------ test login 001 -------")
        self.log.info("------ verifying homepage title ------")
        self.driver = setup
        self.driver.get(self.base_url)
        time.sleep(5)
        actual_title = self.driver.title
        if actual_title == "Guru99 Bank Home Page":
            assert True
            self.driver.close()
            self.log.info("------ home page title test is passed ------")
        else:
            self.driver.save_screenshot("../screenshots/" +
                                        'test_homepage_title.png')
            self.driver.close()
            self.log.error("------ home page title test is failed ------")
            assert False

    @pytest.mark.sanity
    @pytest.mark.regression
    def test_login(self, setup):
        self.log.info("------ verifyin login test ------")
        self.driver = setup
        self.driver.get(self.base_url)
        self.log.info("--- application launched...")
        self.lp = LoginPage(self.driver)
        self.lp.set_user_id(self.user_name)
        self.log.info("--- user id Entered : " + self.user_name)
        self.lp.set_password(self.password)
        self.log.info("--- password Entered : " + self.password)
        self.lp.click_on_login()
        self.log.info("--- clicked on login")
        self.msg = self.driver.find_element_by_xpath("//body").text

        #if self.msg == "Manger Id : mngr285385":
        if "Manger Id :" + " " + self.user_name in self.msg:
            assert True
            self.log.info("------ login test is passed ------")
            self.driver.close()
        else:
            self.driver.save_screenshot(".\\screenshots\\" + "test_login.png")
            self.driver.close()
            self.log.error("------ login test is failed")
            assert False