예제 #1
0
class Test_Login_001:
    base_url = ReadConfig.getApplicationUrl()
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()

    logger = LogGen.log_gen()

    @pytest.mark.regression
    def test_HomePage(self, setup):
        self.logger.info("****************Test_001_Login************")
        self.logger.info(
            "*************** Verifying Home Page Title *************")

        self.driver = setup
        self.driver.get(self.base_url)
        act_url = self.driver.title

        if act_url == "Your store. Login":
            assert True
            self.driver.close()
            self.logger.info(
                "*************** Home Page Title is passed *************")
        else:
            self.driver.save_screenshot(".\\ScreenShots\\" +
                                        "test_HomePage_Title.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 the 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.clickLogin()

        act_title = self.driver.title

        if act_title == 'Dashboard / nopCommerce administration':
            assert True
            self.logger.info(
                "*************** Login test is passed *************")
            self.driver.close()
        else:
            self.driver.save_screenshot(".\\ScreenShots\\" +
                                        "test_HomePage_Title_AfterLogout.png")
            self.driver.close()
            self.logger.error(
                "*************** Login test is failed *************")
            assert False
예제 #2
0
class Test_Login_002_DDT:
    base_url = ReadConfig.getApplicationUrl()
    path = ".//TestData/LoginData.xlsx"
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()

    logger = LogGen.log_gen()

    @pytest.mark.regression
    def test_login_ddt(self, setup):
        self.logger.info("*************** Test_Login_002_DDT *************")
        self.logger.info(
            "*************** Verifying the Login test *************")
        self.driver = setup
        self.driver.get(self.base_url)

        self.lp = LoginPage(self.driver)
        lst_status = []

        rows = ExcelUtils.getRowCount(self.path, 'Sheet1')
        print('No. of rows in the Sheet1: ', rows)

        for r in range(2, rows + 1):
            username = ExcelUtils.readData(self.path, "Sheet1", r, 1)
            password = ExcelUtils.readData(self.path, "Sheet1", r, 2)
            expected_result = ExcelUtils.readData(self.path, "Sheet1", r, 3)
            self.lp.setUsername(username)
            self.lp.setPassword(password)
            self.lp.clickLogin()
            time.sleep(5)

            act_title = self.driver.title

            if act_title == 'Dashboard / nopCommerce administration':
                if expected_result == "Pass":
                    assert True
                    self.logger.info(
                        "*************** Login test is passed *************")
                    self.lp.clickLogout()
                    lst_status.append("Pass")
                elif expected_result == "Fail":
                    self.logger.info(
                        "*************** Login test is failed *************")
                    self.lp.clickLogout()
                    lst_status.append("Fail")
                elif act_title != 'Dashboard / nopCommerce administration':
                    if expected_result == 'Pass':
                        self.logger.info(
                            "*************** Login test is failed *************"
                        )
                        lst_status.append("Fail")
                    elif expected_result == "Fail":
                        self.logger.info(
                            "*************** Login test is Passed} *************"
                        )
                        lst_status.append("Pass")

        if "Fail" not in lst_status:
            self.logger.info("Login DDT is passsed............")
            self.driver.close()
            assert True
        else:
            self.logger.info("Login DDT is failed............")
            self.driver.close()
            assert False

        self.logger.info(" End of Login DDT test")
        self.logger.info(" Completed TC_LoginDDT_002")
class Test_003_AddCustomer:
    baseUrl = ReadConfig.getApplicationUrl()
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.log_gen()

    @pytest.mark.sanity
    def test_addCustomer(self, setup):
        self.logger.info("********Test_003_AddCustomer")
        self.driver = setup
        self.driver.get(self.baseUrl)

        self.driver.maximize_window()

        self.lp = LoginPage(self.driver)
        self.lp.setUsername(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        self.logger.info("********** Login Successful **********")

        self.logger.info("********** Starting Add Customer Test **********")
        self.addCust = AddCustomer(self.driver)
        self.addCust.clickOnCustomerMenu()
        time.sleep(3)
        self.addCust.clickOnCustomerMenuItem()
        self.addCust.clickOnAddNew()

        self.logger.info("********** Providing Customer Info **********")

        self.email = random_generator() + '@gmail.com'
        self.addCust.setEmail(self.email)
        self.addCust.setPassword('Test@123')
        self.addCust.setCustomerRoles('Guests')
        self.addCust.setManagerOfVendor("Vendor 2")
        self.addCust.setGender("Male")
        self.addCust.setFirstName("Rahul")
        self.addCust.setLastName("Singh")
        self.addCust.setDOB("11/09/1980")  #Format: 'DD/MM/YY'
        self.addCust.setCompanyName("QAautomation Testing Ltd.")
        self.addCust.setAdminComment(
            "This content is added for testing purpose")

        self.addCust.clickOnSave()

        self.logger.info(
            "*********** Saving Customer Information *************")

        self.logger.info(
            "********************* Add customer Validation Started **************"
        )

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

        print(self.msg)
        if 'customer has been added successfully.' in self.msg:
            assert True == True
            self.logger.info(
                "************ Add customer Test Passed *************")
        else:
            self.driver.save_screenshot(
                ".\\ScreenShots\\" +
                "test_addCustomer_scr.png")  #screenshot with path +name
            self.logger.info(
                "************ Add customer Test Failed *************")
            assert True == False

        self.driver.close()
        self.logger.info("********* Test Add customer is done **********")
예제 #4
0
class Test0001:
    baseUrl = ReadConfig.get_application_url()
    username = ReadConfig.get_user_name()
    password = ReadConfig.get_user_password()
    logger = LogGen.log_gen()
    driver = None

    def test_correct_login_info(self, setup):
        self.logger.info("logging test with correct info")
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseUrl)
        lp = LoginPage(self.driver)
        lp.set_username(self.username)
        lp.set_password(self.password)
        lp.click_loginbutton()
        url = self.driver.current_url
        if "dashboard" in url.lower():
            assert True
        else:
            assert False

        self.driver.close()

    def test_blank(self, setup):
        self.driver = setup
        self.driver.get(self.baseUrl)
        lp = LoginPage(self.driver)
        lp.click_loginbutton()
        time.sleep(2)
        try:
            errors = self.driver.find_elements_by_xpath('//span[@class="msg-error"]')
            for error in errors:
                if error.is_displayed():
                    print(error.text)
                    self.logger.info("test_blank faile due to error" + error.text)
                else:
                    print('cant read the text')
        except:
            print("wrong")

        self.driver.quit()

    def test_excel_incorrect_email(self, setup):
        row_count = excelUtils.getRowCount("./testData/loginTestData.xlsx", 'Sheet1')
        username = excelUtils.readData("./testData/loginTestData.xlsx", 'Sheet1', 2, 1)
        password = excelUtils.readData("./testData/loginTestData.xlsx", 'Sheet1', 2, 2)
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseUrl)
        lp = LoginPage(self.driver)
        lp.set_username(username)
        lp.set_password(password)
        lp.click_loginbutton()
        try:
            errors = self.driver.find_elements_by_xpath('//span[@class="msg-error"]')
            for error in errors:
                if error.is_displayed():
                    print(error.text)
                    self.logger.info("incorrect email faile due to error" + error.text)
                else:
                    print('cant read the text')
        except:
            print("No")

        self.driver.close()
        print(username, password)

    def test_excel_incorrect_pass(self, setup):
        row_count = excelUtils.getRowCount("./testData/loginTestData.xlsx", 'Sheet1')
        username = excelUtils.readData("./testData/loginTestData.xlsx", 'Sheet1', 3, 1)
        password = excelUtils.readData("./testData/loginTestData.xlsx", 'Sheet1', 3, 2)
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseUrl)
        lp = LoginPage(self.driver)
        lp.set_username(username)
        lp.set_password(password)
        lp.click_loginbutton()
        try:
            self.driver.find_element_by_xpath('/html/body/div[1]/div/div[1]/button')
            assert False
        except:
            allure.attach(self.driver.get_screenshot_as_png(), name="test information creation",
                          attachment_type=AttachmentType.PNG)
            assert True
        self.driver.close()
        print(username, password)