コード例 #1
0
class Test_002_DDT_Login:
    baseURl = ReadConfig.getAppUrl()
    path = ".//testData/login_data_DDT.xlsx"
    logger = LogGen.logGen()

    def test_DDT_login(self):
        self.driver = webdriver.Chrome(
            executable_path=".\\venv\\chromedriver_win32\\chromedriver")
        self.driver.get(self.baseURl)
        self.driver.implicitly_wait(5)
        self.lp = LoginPage(self.driver)

        self.rows = XLUtils.getRowCount(self.path, 'Sheet1')

        list_status = []
        for r in range(2, self.rows + 1):
            self.userName = XLUtils.readData(self.path, 'Sheet1', r, 1)
            self.password = XLUtils.readData(self.path, 'Sheet1', r, 2)
            self.exp = XLUtils.readData(self.path, 'Sheet1', r, 3)

            self.lp.setUserName(self.userName)
            self.lp.setPassword(self.password)
            self.lp.clickLogin()
            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("********Passed********")
                    self.lp.clickLogout()
                    list_status.append('pass')

                elif self.exp == 'fail':
                    self.logger.info("***********Failed**********")
                    self.lp.clickLogout()
                    list_status.append('fail')

            elif act_title != exp_title:
                if self.exp == 'fail':
                    self.logger.info("********Passed********")
                    list_status.append('pass')

                elif self.exp == 'pass':
                    self.logger.info("***********Failed**********")
                    list_status.append('fail')

        if 'fail' not in list_status:
            self.logger.info("Login_DDT_test Passed")
            self.driver.close()
            assert True

        else:
            self.logger.error("Login_DDT_Test is failed")
            self.driver.close()
            assert False

        self.logger.info("**********End of TC_002_DDT_login**********")
class TestSalesModule(BaseClass):
    logger = LogGen.logGen()

    @pytest.mark.order(1)
    def test_sales_module(self, getData):
        driver = self.driver
        # logger = self.getLogger()

        loginpage = LoginPage(driver)

        homepage = loginpage.do_valid_login(TestData.USERNAME,
                                            TestData.PASSWORD)
        self.logger.info('Logged In Successfully')

        homepage.click_allapps()
        salesmodulepage = homepage.select_module()
        # homepage.select_module()
        salesorderpage = salesmodulepage.navigate_to_sales_order()

        salesorderpage.click_create_btn()
        salesorderpage.select_customer(getData['customername'])
        salesorderpage.select_validity(getData['validity'])
        salesorderpage.add_product(getData['product1'])
        # salesorderpage.add_product(getData['product2'])
        # salesorderpage.add_product(getData['product3'])
        # salesorderpage.select_quotation(getData['quotation'])
        salesorderpage.select_payment_terms(getData['paymentterms'])
        salesorderpage.click_confirm()
        # salesorderpage.click_create_invoice()
        # salesorderpage.select_down_payment(getData['downpayment'])
        # salesorderpage.click_create_nd_view()
        # salesorderpage.click_validate()
        # salesorderpage.click_register()
        # salesorderpage.click_validate_register()
        # salesorderpage.click_send_print()
        # salesorderpage.click_email_checkbox()
        # salesorderpage.click_print()
        # salesorderpage.click_ok_btn()
        time.sleep(5)
        self.logger.info('Record Created Successfully')

        salesorderpage.open_sales_list()
        salesorderpage.click_on_created_order()
        salesorderpage.click_cancel()
        salesorderpage.click_actions_and_delete()
        self.logger.info('Record Deleted Successfully')

        TestData.write_valid_result()
        homepage.do_logout()
        self.logger.info('Logged Out Successfully')

    @pytest.fixture(params=TestData.getSalesTestData())
    def getData(self, request):
        return request.param
コード例 #3
0
class Test_002_AddCustomer:
    baseUrl = ReadConfig.getBaseUrl()
    username = ReadConfig.getUserName()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_addCustomer(self, setup):
        self.logger.info("******Test_002_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.clickOnCustomersMenu()
        time.sleep(2)
        self.addCust.clickOnCustomersmenuitem()
        self.addCust.clickOnAddnew()
        self.logger.info("****providing Customer info******")
        self.email = random_generator() + "@gmail.com"
        self.addCust.setEmail(self.email)
        self.addCust.setPassword("Test123")
        self.addCust.setFirstname("samy")
        self.addCust.setLastName("John")
        self.addCust.setGender("Male")
        self.addCust.setDob("12/13/1987")
        self.addCust.setCompanyName("Apple")
        self.addCust.setIsTaxexmpt()
        self.addCust.setCustomerRoles("")
        self.addCust.selectMangerofVendor("vendor 1")
        self.addCust.setIsActive()
        self.addCust.setAdminContent("Thi sis my comments")
        self.addCust.Clicksave()

        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 "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")
            self.logger.info("***** Add Customer Test Failed********")
            assert True == False
        self.driver.close()
        self.logger.info("****** Ending add customer Test*********")
コード例 #4
0
class Test_001_Login:
    baseURL = ReadConfig.getApplicationUrl()
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_homePageTitle(self, setup):
        self.logger.info("**********Test_001_Login**********")
        self.logger.info("**********verifying test_homePageTitle**********")
        self.driver = setup
        self.driver.get(self.baseURL)
        actual_title = self.driver.title
        if actual_title == "MARS Iris":
            assert True
            self.driver.close()
            self.logger.info(
                "**********verifying test_homePageTitle passed**********")
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_homePageTitle.png")
            self.driver.close()
            self.logger.error(
                "******************verifying test_homePageTitle failed**********"
            )
            assert False

    def test_login(self, setup):
        self.logger.info("**********verifying test_login**********")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = LoginPage(self.driver)
        self.lp.setUserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        actual_title = self.driver.title
        if actual_title == "MARS Iris":
            assert True
            self.driver.close()
            self.logger.info("**********verifying test_login passed**********")
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png")
            self.driver.close()
            self.logger.error(
                "**********verifying test_login failed**********")
            assert False
コード例 #5
0
class Test_001_Login:
    baseUrl = ReadConfig.getBaseUrl()
    username = ReadConfig.getUserName()
    password = ReadConfig.getPassword()
    logger1 = LogGen.logGen()

    def test_HomePageTitle(self, setup):
        self.logger1.info("*********Verify Home page title**************")
        self.driver = setup
        self.driver.get(self.baseUrl)
        act_title = self.driver.title
        if act_title == "Your store. Login":

            self.driver.close()
            assert True
            self.logger1.info("*****Home page title test is pass******")




        else:
            self.driver.save_screenshot(".//Screenshots//" + "test_HomePageTitle.png")
            self.driver.close()
            self.logger1.info("****Home page title is failed*****")
            assert False

    def test_Login(self, setup):
        self.logger1.info("***** verify Login *****")
        self.driver = setup
        self.driver.get(self.baseUrl)
        self.lp = Loginpage(self.driver)
        self.lp.setUsername(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        actual_title = self.driver.title
        if actual_title == "Dashboard / nopCommerce administration":
            assert True
            self.logger1.info("****Login test is pass***")
            self.driver.close()

        else:
            assert False
            self.logger1.error("***Login Test is failed*****")
            self.driver.close()
コード例 #6
0
class Test_001_Login:
    baseURl = ReadConfig.getAppUrl()
    userName = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_HomePageTitle(self):
        self.logger.info("****Test_001_Login****")
        self.driver = webdriver.Chrome(
            executable_path=".\\venv\\chromedriver_win32\\chromedriver")
        self.driver.get(self.baseURl)
        act_title = self.driver.title
        if act_title == "Your store. Login":
            assert True
            self.driver.close()
            self.logger.info("*****Test is passed******")
        else:
            self.driver.save_screenshot(".\screenshots\page.png")
            self.driver.close()
            self.logger.error("*****Test is Failed******")
            assert False

    def test_login(self):
        self.driver = webdriver.Chrome(
            executable_path="C:\Drivers\chromedriver_win32\chromedriver")
        self.driver.get(self.baseURl)
        self.lp = LoginPage(self.driver)
        self.lp.setUserName(self.userName)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        actual_title = self.driver.title
        if actual_title == "Dashboard / nopCommerce administration":
            self.driver.close()
            self.logger.info("*****Test is passed******")
            assert True

        else:
            self.driver.save_screenshot(".\screenshots\loginPage.png")
            self.driver.close()
            self.logger.error("*****Test is Failed******")
            assert False
コード例 #7
0
class Test_SearchCustomerByEmail_004:
    baseURl = ReadConfig.getAppUrl()
    userName = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_searchCustomerByEmail(self):
        self.logger.info("************* SearchCustomerByEmail_004 **********")
        self.driver = webdriver.Chrome(
            executable_path=".\\venv\\chromedriver_win32\\chromedriver")
        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 succesful **********")

        self.logger.info(
            "******* Starting Search Customer By Email **********")

        self.addcust = AddCustomer(self.driver)
        self.addcust.clickOnCustomersMenu()
        self.addcust.clickOnCustomersMenuItem()

        self.logger.info(
            "************* searching customer by emailID **********")
        searchcust = SearchCustomer(self.driver)
        searchcust.setEmail("*****@*****.**")
        searchcust.clickSearch()
        time.sleep(5)
        status = searchcust.searchCustomerByEmail(
            "*****@*****.**")
        self.driver.close()
        assert True == status
        self.logger.info(
            "***************  TC_SearchCustomerByEmail_004 Finished  *********** "
        )
コード例 #8
0
class Test_homepage:
    baseURL = ReadConfig.getUrl()
    email = ReadConfig.getEmail()
    invalid_email = ReadConfig.getInvalidemail()
    password = ReadConfig.getPassword()
    search = ["dress", "t-shirt"]
    invalid_search = ["car", "tree", "phone", "mouse", "keyboard"]

    logger = LogGen.logGen()

    def test_login(self, setup):
        self.logger.info(
            "**************** Test_homepage **********************")
        self.logger.info(
            "**************** Login test initialized **********************")
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseURL)
        self.driver.find_element_by_xpath(
            "//a[contains(text(),'Sign in')]").click()
        self.lp = LoginStep(self.driver)
        self.lp.setEmail(self.email)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        if self.driver.find_element_by_xpath(
                "//p[contains(text(),'Welcome to your account. Here you can manage all o')]"
        ).is_displayed():
            assert True
            self.logger.info(
                "******************** Login test passed *****************")
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png")
            self.logger.error(
                "******************** Login test failed *****************")
            assert False
        self.driver.close()

    def test_invalid_login(self, setup):
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseURL)
        self.driver.find_element_by_xpath(
            "//a[contains(text(),'Sign in')]").click()
        self.lp = LoginStep(self.driver)
        self.lp.setEmail(self.invalid_email)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        if self.driver.find_element_by_xpath(
                "//li[contains(text(),'Invalid email address.')]"
        ).is_displayed():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_invalid_login.png")
            assert False
        self.driver.close()

    def test_invalid_search(self, setup):
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseURL)
        self.wrong_term = RandomGen(self.driver)
        self.driver.find_element_by_id("search_query_top").clear()
        self.wrong_term.invalid_gen(self.invalid_search)
        self.driver.find_element_by_xpath(
            "//header/div[3]/div[1]/div[1]/div[2]/form[1]/button[1]").click()
        no_results = self.driver.find_element_by_class_name(
            "heading-counter").text
        if int(no_results[0]) == 0:
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_invalid_search.png")
            assert False
        self.driver.close()

    def test_valid_search(self, setup):
        self.driver = setup
        self.driver.maximize_window()
        self.driver.get(self.baseURL)
        self.correct_term = RandomGen(self.driver)
        self.driver.find_element_by_id("search_query_top").clear()
        self.correct_term.valid_gen(self.search)
        self.driver.find_element_by_xpath(
            "//header/div[3]/div[1]/div[1]/div[2]/form[1]/button[1]").click()
        results = self.driver.find_element_by_class_name(
            "heading-counter").text
        if int(results[0]) > 0:
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_valid_search.png")
            assert False
        self.driver.close()
コード例 #9
0
class Test_003_AddCustomer:
    baseURl = ReadConfig.getAppUrl()
    userName = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_addCustomer(self):
        self.logger.info("************* Test_003_AddCustomer **********")
        self.driver = webdriver.Chrome(
            executable_path=".\\venv\\chromedriver_win32\\chromedriver")
        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 succesful **********")

        self.logger.info("******* Starting Add Customer Test **********")

        self.addcust = AddCustomer(self.driver)
        self.addcust.clickOnCustomersMenu()
        self.addcust.clickOnCustomersMenuItem()

        self.addcust.clickOnAddnew()

        self.logger.info("************* Providing customer info **********")

        self.email = random_generator() + "@gmail.com"
        self.addcust.setEmail(self.email)
        self.addcust.setPassword("test123")
        self.addcust.setCustomerRoles("Guests")
        self.addcust.setManagerOfVendor("Vendor 2")
        self.addcust.setGender("Male")
        self.addcust.setFirstName("Pavan")
        self.addcust.setLastName("Kumar")
        self.addcust.setDob("7/05/1985")  # Format: D / MM / YYY
        self.addcust.setCompanyName("busyQA")
        self.addcust.setAdminContent("This is for testing.........")
        self.addcust.clickOnSave()

        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_scr.png")  # Screenshot
            self.logger.error(
                "********* Add customer Test Failed ************")
            assert False

        self.driver.close()
        self.logger.info("******* Ending Add customer test **********")
コード例 #10
0
class Test_002_homePage:
    baseURL = ReadConfig.getApplicationUrl()
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.logGen()

    def test_succesfulLogin(self, setup):
        self.logger.info("*****Verfying Test_002_homePage*********")
        self.logger.info("*****Verfying if login successful*********")
        self.driver = setup
        self.driver.get(self.baseURL)
        loginPage = LoginPage(self.driver)
        loginPage.setUserName(self.username)
        loginPage.setPassword(self.password)
        loginPage.clickLogin()
        homepage = HomePage(self.driver)
        if homepage.isLoginSuccesful:
            assert True
            self.logger.info("**********Login Succesful**********")
            self.driver.close()
        else:
            self.logger.info("Login Failed")
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_successful_login.png")
            self.driver.close()
            assert False

    @pytest.mark.dashboard
    def test_dashboard_clickable(self, setup):
        self.logger.info("Verifying dashboard.")
        self.driver = setup
        self.driver.get(self.baseURL)
        loginPage = LoginPage(self.driver)
        loginPage.setUserName(self.username)
        loginPage.setPassword(self.password)
        loginPage.clickLogin()
        homePage = HomePage(self.driver)
        homePage.click('profile', self.logger)
        try:
            if self.driver.find_element(
                    By.XPATH,
                    "//span[text()='Dashboard']/parent::div").is_displayed():
                assert True
                self.logger.info("Dashboard visible.")
                self.driver.close()
            else:
                self.driver.save_screenshot(".\\Screenshots\\" +
                                            "test_dashboard_clickable.png")
                self.logger.info("Dashboard NOT visbile.")
                self.driver.close()
                assert False
        except Exception as e:
            self.logger.info(e)
            self.logger.info("Dashboard NOT clickable.")
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_dashboard_clickable.png")
            assert False

    @pytest.mark.logout
    def test_logout(self, setup):
        self.logger.info("Verifying logout functionality.")
        self.driver = setup
        self.driver.get(self.baseURL)
        loginPage = LoginPage(self.driver)
        loginPage.setUserName(self.username)
        loginPage.setPassword(self.password)
        loginPage.clickLogin()
        homepage = HomePage(self.driver)
        homepage.logout(self.logger)