class Test_SearchCustomerByName_005:
    baseURL = ReadConfig.GetApplicationURL()
    username = ReadConfig.GetUseremail()
    password = ReadConfig.GetPassword()
    logger = LogGen.loggen()

    @pytest.mark.regression
    def test_searchCustomerByName(self, setup):
        self.logger.info("************ SearchCustomerByName_005 ********** ")
        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 Search Customer By Name ********** ")

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

        time.sleep(5)

        self.logger.info("************ searching customer by Name ********** ")
        searchcust = SearchCustomer(self.driver)
        searchcust.setFirstName("Victoria")
        searchcust.setLastName("Terces")
        searchcust.clickSearch()
        time.sleep(5)
        status = searchcust.searchCustomerByName("Victoria Terces")
        self.driver.close()
        assert True == True
        self.logger.info(
            "************* TC_SearchCustomerByName_005 Finished ************")
Exemplo n.º 2
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  *********** "
        )
Exemplo n.º 3
0
class Test_SearchCustomerByEmail_004:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()  # Logger

    @pytest.mark.regression
    def test_searchCustomerByEmail(self, setup):
        self.logger.info("************* SearchCustomerByEmail_004 **********")
        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 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  *********** "
        )
Exemplo n.º 4
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 ******************")
class Test_004_SearchCustomerByEmail:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()

    @pytest.mark.regression
    def test_SearchCustomerByEmail(self, setup):
        self.logger.info("***** Test_004_SearchCustomerByEmail")
        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()
        self.logger.info("***** Login successful")

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

        self.addcust = AddCustomer(
            self.driver)  # associating page object addcustomer
        self.addcust.clickOnCustomerMenu()
        self.addcust.clickOnCustomerMenuItem()

        searchcust = SearchCustomer(self.driver)
        s_email = "*****@*****.**"
        searchcust.setSEmail(s_email)

        searchcust.clickSearch(
        )  #<<<== comment out if you want to run the table coz email id is always unique

        time.sleep(5)
        status = searchcust.searchCustomerByEmail(s_email)
        self.logger.info(status)
        if status == True:
            assert True
        else:
            assert False
class Test_002_login_DDT:
    URL = ReadConfig.getapplicationURL()
    path=r"C:\\Users\\Priyabrata Debolina\\PycharmProjects\\Selenium with python\\TestData\practice.xlsx"
    logger=LogGen.loggen()
    @pytest.mark.regression
    def test_ddt(self,setup):
        self.logger.info("*****Test_002_login*****")
        self.logger.info("*****Verifying Login DDT test*****")
        self.driver=setup
        self.driver.get(self.URL)

        self.lp=login(self.driver)
        self.lp.clickLogin()
        self.rows=XLUtils.getRowcount(self.path,'Sheet1')

        for r in range(2,self.rows+1):
            self.user=XLUtils.readData(self.path,'Sheet1',r,1)
            self.pwd=XLUtils.readData(self.path,'Sheet1',r,2)
            self.driver.save_screenshot('C:\\Users\\Priyabrata Debolina\\PycharmProjects\\Selenium with python\\Screenshots\\test_DDT.png')


        self.lp.username(self.user)
        self.lp.password(self.pwd)
class Test_search_CustomerByEmail_004():
    baseUrl = ReadConfig.getApplicationUrl()
    username = ReadConfig.getUsername()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()

    def test_searchCustomerByEmail(self, setup):
        self.logger.info("**********search customer by email 004*************")
        self.driver = setup
        self.driver.get(self.baseUrl)
        self.driver.maximize_window()

        self.lp = Login(self.driver)
        self.lp.setUserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogin()
        self.logger.info("***********Login successfull***********")

        # self.logger("***********starting search customer by email************")

        self.addCustomer = AddCustomer(self.driver)

        self.addCustomer.click_On_Customer_Menu()
        self.addCustomer.click_On_Customer_Menu_item()



        self.logger.info("*********search by email id***********")

        sercCustomer = searchCustomer(self.driver)
        sercCustomer.setEmail("*****@*****.**")
        sercCustomer.submitClick()
        time.sleep(5)

        status = sercCustomer.searchCustomerByEmail("*****@*****.**")
        assert True == status
        self.logger.info("*********TC SEARCH CUSTOMER BY EMAIL finished.......")
class Test_searchCustomerEmail004:
    baseURL = ReadConfig.readApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()

    def test_searchCustomerByEmail(self):

        self.logger.info(
            "*********** search customer test 004 started***************")
        self.logger.info(
            "*********** logging with username and password******")
        self.driver = webdriver.Chrome("C:\Program Files\chromedriver.exe")
        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("**********user logged in to website successfully")

        self.logger.info("*********** search customer by mail or name started")
        self.addcust = AddCustomer(self.driver)
        self.addcust.clickOnCustomerMenu()
        self.addcust.clickOnCustomerMenuItem()

        self.logger.info("********** serach customer by email")
        searchcust = SearchCustomer(self.driver)
        searchcust.setEmail("*****@*****.**")
        searchcust.clickonSearch()
        time.sleep(5)
        status = searchcust.searchCustomerByEmail(
            "*****@*****.**")
        assert True == status
        self.logger.info(
            "************ test search customer by email finished********")
        self.driver.close()
Exemplo n.º 9
0
class Test_001_login(BaseClass):

    baseURL = ReadConfig.getApplicationURL()
    Email = ReadConfig.getEmail()
    Password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    @allure.severity(allure.severity_level.MINOR)
    def test_homePageTitle(self, setup):

        self.logger.info("*********Home Page Test Started***********")

        self.logger.info("********Verifying HomePage Title***********")

        actualTitle = self.driver.title

        assert actualTitle == "Your store. Login"

    @allure.severity(allure.severity_level.MINOR)
    def test_login(self):

        self.logger.info("*********Login Test Started***********")

        self.logger.info("********Verifying Logim Function***********")

        self.lp = Login(self.driver)

        self.lp.doLogin(self.Email, self.Password)

        userName = self.lp.getUserName()

        actualTitle = self.lp.getTitle()

        assert actualTitle == "Dashboard / nopCommerce administration"

        assert userName == 'John Smith'
Exemplo n.º 10
0
class Test_002_logger_Login:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    def test_logger_login(self, setup):
        self.logger.info("------ Test_002_logger_Login ------")
        self.logger.error("dfdfjdfjdf")
        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()
        act_title = self.driver.title
        if act_title == "Dashboard / nopCommerce administration":
            assert True
            self.driver.close()
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png")
            self.driver.close()
            assert False
Exemplo n.º 11
0
class Test_001_login:
    URL = ReadConfig.getapplicationURL()
    username = ReadConfig.username()
    password = ReadConfig.password()
    logger = LogGen.loggen()

    @pytest.mark.sanity
    @pytest.mark.regression
    def testhomepage(self, setup):
        self.logger.info("*****Test_001_login*****")
        self.logger.info("*****Verifying Home page title*****")
        self.driver = setup
        self.driver.get(self.URL)
        act_title = self.driver.title
        if act_title == "nopCommerce demo store":
            assert True
            self.logger.info("*****Test Case passed*****")
        else:
            self.logger.info("*****Test Case Failed****")
        self.lp = login(self.driver)
        self.lp.clickLogin()
        self.lp.username(self.username)
        print()
        self.lp.password(self.password)
        self.driver.save_screenshot(
            "C:\\Users\\Priyabrata Debolina\\PycharmProjects\\Selenium with python\\Screenshots\\testhomepage.png"
        )
        self.driver.close()

    @pytest.mark.regression
    def testregister(self, setup):
        self.driver = setup
        self.driver.get(self.URL)
        self.driver.maximize_window()
        self.driver.find_element_by_class_name('ico-register').click()
        self.driver.close()
class Test_005_Searchcustomerbyname:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUserEmail()
    password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    @pytest.mark.regression
    def test_searchcustomerbyname(self, setUp):
        self.logger.info("SearchCustomer")
        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("Search Customer by Email")

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

        searchcust = SearchCustomer(self.driver)
        searchcust.setFirstName("james")
        searchcust.setLastName("pan")
        searchcust.clickSearch()
        time.sleep(5)
        status = searchcust.searchCustomerbyName("James Pan")
        assert True == status

        self.logger.info("End of search customer by name test case ")
        self.driver.close()
Exemplo n.º 13
0
class Test_SearchOrdersByEmail_006:

    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUserEmail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()  # Logger

    def test_searchOrdersByEmail(self, setup):
        self.logger.info("************* TC_SearchOrdersByEmail_006 **********")
        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("******* Navigating to Orders Page **********")
        self.so = searchOrders(self.driver)
        self.so.clickSales()
        self.driver.implicitly_wait(2)
        self.so.clickOrders()
        self.driver.implicitly_wait(2)
        self.logger.info(
            "******* Successfully landed on Orders Page **********")

        self.logger.info("******* Searching Orders By Email **********")
        self.so.setEmail("*****@*****.**")
        self.so.clickSearch()
        flag = self.so.searchOrderByEmail("*****@*****.**")
        assert flag
        self.driver.close()
        self.logger.info(
            "************* TC_SearchOrdersByEmail_006 Finished **********")
Exemplo n.º 14
0
class Test_001_Login:
    logger = LogGen.loggen()

    def test_homePageTitle(self, setup):
        self.logger.info(
            "*********************************Test_001_Login*************************************"
        )
        self.logger.info(
            "*********************************test_homePageTitle*************************************"
        )
        self.driver = setup
        self.driver.get(ReadConfig.getApplicationURL())
        act_title = self.driver.title
        if act_title == "Your store. Login":
            assert True
            self.driver.close()
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_homePageTitle.png")
            self.driver.close()
            assert False

    def test_Login(self, setup):
        self.driver = setup
        self.driver.get(ReadConfig.getApplicationURL())
        self.loginObject = LoginPage(self.driver)
        self.loginObject.setusername(ReadConfig.getUsername())
        self.loginObject.setpassword(ReadConfig.getPassword())
        self.loginObject.login()
        act_title = self.driver.title
        self.driver.close()
        print(act_title)
        if act_title == "Dashboard / nopCommerce administration":
            assert True
        else:
            assert False
Exemplo n.º 15
0
class Test_001_Add_Customer:

    logger = LogGen.loggen()

    @pytest.mark.sanity
    def test_add_customer(self, setup):
        self.driver = setup
        self.driver.get(ConfigReader.get_application_url())
        self.lg = Login(self.driver)
        self.lg.set_username(ConfigReader.get_login_username())
        self.lg.set_password(ConfigReader.get_login_password())
        self.lg.click_login()
        self.logger.info("Login Successful")
        self.logger.info("starting add customer test")
        self.add_customer = AddCustomerTest(self.driver)
        self.add_customer.click_on_customer_main_manu()
        self.add_customer.click_on_customer_mainItem()
        self.add_customer.click_on_add_new_button()
        self.logger.info("Providing customer information")
        self.email = randon_generator() + "@gmail.com"
        self.add_customer.set_email(self.email)
        self.add_customer.set_password(randon_generator(15))
        self.add_customer.set_first_name(randon_generator(6))
        self.add_customer.set_last_name(randon_generator(6))
        self.add_customer.click_on_gender("male")
        self.add_customer.set_date_of_birth("12/02/1986")
        self.add_customer.set_company_name("moreyeahs")
        self.add_customer.click_on_is_tax_exempt()
        self.add_customer.set_customer_role()
        self.add_customer.set_new_letter("Your store name")
        self.add_customer.select_manager_of_vendor()
        self.add_customer.click_on_active_button()
        self.add_customer.click_on_comment(randon_generator(40))
        self.add_customer.click_on_save_button()
        self.add_customer.check_customer_added_successfully()
        self.driver.close()
Exemplo n.º 16
0
class Test_002_DDT_Login:
    baseURL = ReadConfig.getApplicationURL()
    path = ".//TestData/LoginData.xlsx"
    logger = LogGen.loggen()

    @pytest.mark.regression
    def test_login_ddt(self, setup):
        self.logger.info("-------- Test_002_DDT_Login --------")
        self.logger.info("-------- Verifying Login DDT test ---------")
        self.driver = setup
        self.driver.get(self.baseURL)

        self.lp = LoginPage(self.driver)

        self.rows = XLUtils.getRowCount(self.path, 'Sheet1')
        print("Number of Rows in the Excel", self.rows)
        lst_status = []  # empty list variable

        for r in range(2, self.rows + 1):
            self.user = 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.logger.info(r)
            #self.logger.info(self.user)
            #self.logger.info(self.password)
            #self.logger.info(self.exp)

            self.lp.setUserName(self.user)
            self.lp.setPassword(self.password)
            self.lp.clickLogin()
            time.sleep(5)



            act_title = self.driver.title
            #self.logger.info(act_title)
            exp_title = "Dashboard / nopCommerce administration"

            if act_title == exp_title:
                if self.exp == "Pass":
                    self.logger.info("*** Passed ***")
                    self.lp.clickLogout()
                    lst_status.append("Pass")
                elif self.exp == "Fail":
                    self.logger.info("*** Failed ***")
                    self.lp.clickLogout()
                    lst_status.append("Fail")
            elif act_title != exp_title:  # can also be if statement
                if self.exp == "Pass":
                    self.logger.info("*** Failed ***")
                    lst_status.append("Fail")
                elif self.exp == "Fail":
                    self.logger.info("*** Passed1 ***")
                    lst_status.append("Pass")

        self.logger.info(lst_status)

        if "Fail" not in lst_status:
            self.logger.info("*** Login DDT test passed ***")
            self.driver.close()
            assert True
        else:
            self.logger.info("*** Login DDT test failed ***")
            self.driver.close()
            assert False
        self.logger.info("-------- End of Test_002_DDT_Login --------")
        self.logger.info("-------- Completed Login DDT test ---------")
Exemplo n.º 17
0
class Test_AddCustomer:

    baseURL= ReadConfig.getApplicationURl()
    userName= ReadConfig.getUseremail()
    userPassword =ReadConfig.getPassword()
    logger= LogGen.loggen()

    @pytest.mark.regression
    @pytest.mark.sanity
    def test_Validate_addCustomer(self,setupBrowserDriver):
        self.logger.info("********* testcase 3 login*************")
        self.driver=setupBrowserDriver
        self.driver.get(self.baseURL)
        self.logger.info("********* login *************")
        self.lp = LoginPage(self.driver)
        self.lp.setUserName(self.userName)
        self.lp.setPassword(self.userPassword)
        self.lp.clickLogin()
        self.logger.info("****************** Admin Logged In *************************")
        self.ac = AddCustomer(self.driver)
        self.driver.maximize_window()
        self.ac.clickonCustomerMenu()
        self.ac.clickonCustomerMenuItem()
        self.ac.clickonAddCustomerBtn()

# Enter Emailid first randomly we create a id and merge with gmail.com

        self.emailid=random_generator()+'@gmail.com'
        self.ac.setEmail(self.emailid)
        self.ac.setPasword("abc123")
        self.ac.setFirstName("sam")
        self.ac.setLastName("Billing")
        self.ac.setGender("female")
        self.ac.setDOB("12-11-2000")
        self.ac.setCompanyName("company")
        self.ac.setIstaxexempt("true")
        self.ac.setManagerofvendor(1)
        print("list vendor ")
        self.ac.setAdminContent("admin content")
        self.ac.clickOnSave()

        self.msg=self.driver.find_element_by_xpath("//div[@class='alert alert-success alert-dismissable']").text

        if 'customer has been added successfully.' in self.msg:
            assert True==True
            self.logger.info("**************** customer has been added successfully. ***************")
            self.driver.close()
        else:
            assert True==False
            self.logger.critical("**************** customer has been not added successfully. ***************")
            self.driver.close()

    @pytest.mark.regression
    def test_Validate_Failing_addCustomer(self, setupBrowserDriver):
        self.logger.info("********* testcase 4 login*************")
        self.driver = setupBrowserDriver
        self.driver.get(self.baseURL)
        self.logger.info("********* login *************")
        self.lp = LoginPage(self.driver)
        self.lp.setUserName(self.userName)
        self.lp.setPassword(self.userPassword)
        self.lp.clickLogin()
        self.logger.info("****************** Admin Logged In *************************")
        self.ac = AddCustomer(self.driver)
        self.driver.maximize_window()
        self.ac.clickonCustomerMenu()
        self.ac.clickonCustomerMenuItem()
        self.ac.clickonAddCustomerBtn()
        self.ac.clickOnSave()
        self.logger.info("************ without entering register info click on save")

        self.msg=self.driver.find_element_by_xpath("//div[@class='alert alert-danger alert-dismissable']").text
        print("print ing msge  ::: ",self.msg)

        if "Valid Email is required for customer to be in 'Registered' role" in self.msg:
            assert True== True
            self.logger.info("*********** testcase pass when no info entered and not saving customer ************* ")
            self.driver.close()
        else:
            assert True==False
            self.logger.info("*********** testCase Failed when no info entered and saving customer ************* ")
            self.driver.close()
Exemplo n.º 18
0
class Test_Alarm_Alert_Page_Titles(BaseTest):
    logger = LogGen.loggen()
    mail_id = ReadConfig.sisaManager()
    password = ReadConfig.password()

    def test_alarm_alert_page_title(self):
        self.logger.info(
            "*********************Test_001_Alarm Alert Page Title***********************"
        )
        self.logger.info(
            "****************Verify whether Alarm Alert list page is opened when clicked on Alarm Alert Menu ******************"
        )
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        exp_res = "Alarm Alerts List"
        act_res = self.driver.find_element(
            By.XPATH, "//h3[@class='panel-title inline-block']").text
        if exp_res == act_res:
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "alarm_alert_page_title.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info(
            "********************* Test_001_Passed ***********************")

    def test_alarm_alert_create_ticket(self):
        self.logger.info(
            "*********************Test_002_Alarm Alert_Create_Tickets_Page Title***********************"
        )
        self.logger.info(
            "****************Verify whether Ticket creation page is opened when clicked on Create Ticket ******************"
        )
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.checkbox()
        time.sleep(2)
        self.Alarm_obj.create_tickets()
        time.sleep(2)
        exp_res = "Create Ticket for Alarms"
        act_res = self.driver.find_element(
            By.XPATH,
            "//span[@id='ui-id-2' and text()='Create Ticket for Alarms']").text
        self.Alarm_obj.create_ticket_close()
        if exp_res == act_res:
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "alarm_alert_create_ticket.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info(
            "********************* Test_002_Passed ***********************")

    def test_alarm_alert_view_message_title(self):
        self.logger.info(
            "*********************Test_003_Alarm Alert View Message Page Title***********************"
        )
        self.logger.info(
            "****************Verify whether View Message is window is opened when clicked on View Message ******************"
        )
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.view_message()
        exp_res = "Message"
        act_res = self.driver.find_element(
            By.XPATH, "//span[@id='ui-id-1' and text()='Message']").text
        self.Alarm_obj.view_close()
        if exp_res == act_res:
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "alarm_alert_view_message_title.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info(
            "********************* Test_003_Passed ***********************")
Exemplo n.º 19
0
class Test_003_AddCustomer:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()

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

        self.lp = LoginPage(self.driver)
        self.lp.SetUserName(self.username)
        self.logger.info("--- Username Entered :" + self.username)
        self.lp.SetPassword(self.password)
        self.logger.info("--- Password Entered :" + self.password)
        self.lp.ClickLogin()
        self.logger.info("--- clicked on login")
        self.logger.info("*************** Login Successful ****************")

        self.logger.info(
            "*************** Starting Add Customer Test ************")
        self.addcust = AddCustomer(self.driver)
        self.addcust.ClickOnCustomersMenu()
        self.logger.info("--- clicked on Customers Menu")
        self.addcust.ClickOnCustomersMenuItem()
        self.logger.info("--- clicked on Customers Menu Item")
        self.addcust.ClickOnAddnew()
        self.logger.info("--- clicked on Add New")

        self.logger.info("*********** Providing customer info ************")
        self.email = random_generator() + "@gmail.com"
        self.addcust.setEmail(self.email)
        self.addcust.setPassword("test123")
        self.addcust.setFirstname("Prashant")
        self.addcust.setLastname("Khande")
        self.addcust.setGender("Male")
        self.addcust.setDob("4/09/1996")  # Format : D/MM/YYYY
        self.addcust.setCompantName("KWPL")
        #self.addcust.setNewsletter()
        self.addcust.setCustomerRoles("Guests")
        self.addcust.setManagerofVendor('Vendor 2')
        self.addcust.setAdminContent("This is foe 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 "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
            self.logger.error("********** Add Customer Test Failed **********")
            self.driver.close()
            assert True == False

        self.driver.close()
        self.logger.info(
            "********** Ending Test_003_AddCustomer *************")
Exemplo n.º 20
0
class Test_002_DDT_Login:
    baseURL = ReadConfig.getApplicationURL()  # URL정보를 가져옴
    path = '.\\testData\\LoginData.xlsx'  # Test Data 파일 경로
    logger = LogGen.loggen()  # 로그 생성을 위한 인스턴스

    @pytest.mark.regression
    def test_login_ddt(self, setup):
        self.logger.info("********** Test_002_DDT_Login **********")
        self.logger.info("********** verifying login DDT test **********")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.driver.maximize_window()

        self.lp = LoginPage(self.driver)

        # Test data 의 행 숫자를 가져옴
        self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1')
        print("Number of rows in Excel:", self.rows)

        # PASS/FAIL 정보를 넣어줄 빈 리스트 생성
        lst_status = []

        for r in range(2, self.rows + 1):
            # Test data에서 엑셀 셀값을 가져옴
            self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1)
            self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2)
            self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3)
            self.driver.get(self.baseURL)
            self.lp.setUserName(self.user)
            self.lp.setPassword(self.password)
            self.lp.clickLogin()
            time.sleep(5)

            act_title = self.driver.title
            exp_title = "SK open API"

            if act_title == exp_title:
                if self.exp == "Pass":
                    self.logger.info("********** Passed")
                    self.lp.clickLogout()
                    lst_status.append("Pass")
                elif self.exp == "Fail":
                    self.logger.info("********** Failed")
                    self.lp.clickLogout()
                    lst_status.append("Fail")
            elif act_title != exp_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("********** Login DDT Test Passed **********")
            self.driver.close()
            assert True
        else:
            self.logger.info("********** Login DDT Test Failed **********")
            self.driver.close()
            assert False

        self.logger.info("********** End of Login DDT Test **********")
        self.logger.info("********** Completed TC_LoginDDT_002 **********")
Exemplo n.º 21
0
class Test_003_AddCustomer:
    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getpassword()
    logger = LogGen.loggen()  # Logger

    @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 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 '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 **********")
Exemplo n.º 22
0
 def test_log(self):
     logs = LogGen.loggen()
     print(self.logs)
     self.logs.info("***** Test_001_Login *****")
class Test_002_DDT_Login():
    baseURL = ReadConfig.getApplicationURL()
    path = ".//TestData/LoginData1.xlsx"
    logger = LogGen.loggen()  # Logger

    @pytest.mark.regression
    def test_login_ddt(self, setup):
        self.logger.info("******* Starting Test_002_DDT_Login Test **********")
        self.logger.info("******* Starting Login DDT Test **********")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.driver.maximize_window()
        self.lp = LoginPage(self.driver)

        self.rows = XLUtils.getRowCount(self.path, 'Sheet1')
        print('Number of rows...', self.rows)
        lst_status = []

        for r in range(2, self.rows + 1):
            self.user = 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.user)
            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()
                    lst_status.append("Pass")
                elif self.exp == 'Fail':
                    self.logger.info("**** failed ****")
                    self.lp.clickLogout()
                    lst_status.append("Fail")

            elif act_title != exp_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")
            print(lst_status)
        if "Fail" not in lst_status:
            self.logger.info("******* DDT Login test passed **********")
            self.driver.close()
            assert True
        else:
            self.logger.error("******* DDT Login test failed **********")
            self.driver.close()
            assert False

        self.logger.info("******* End of Login DDT Test **********")
        self.logger.info(
            "**************** Completed  TC_LoginDDT_002 ************* ")
class Test_Element_Presence(BaseTest):
    logger= LogGen.loggen()
    mail_id = ReadConfig.sisaManager()
    password = ReadConfig.password()


    def test_export_to_excel_presence(self):
        self.logger.info("*********************Test_002_01_Export to Excel button visibility***********************")
        self.logger.info(
            "****************Verify whether Import button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_export_all_to_excel = self.driver.find_element(By.XPATH, "//button[@id='btnExcel']")
        if ele_export_all_to_excel.is_displayed() and ele_export_all_to_excel.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "export_to_excel_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_01_Passed ***********************")



    def test_create_ticket_presence(self):
        self.logger.info("*********************Test_002_02_Create Tickets button visibility***********************")
        self.logger.info(
            "****************Verify whether Create Tickets button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_create_ticket = self.driver.find_element(By.XPATH, "//button[@id='btnTicket']")
        if ele_create_ticket.is_displayed() and ele_create_ticket.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "create_ticket_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_02_Passed ***********************")


    def test_import_presence(self):
        self.logger.info("*********************Test_002_03_Import button visibility***********************")
        self.logger.info(
            "****************Verify whether Import button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_import = self.driver.find_element(By.XPATH, "//button[@type='submit' and text()='Import']")
        if ele_import.is_displayed() and ele_import.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "import_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_03_Passed ***********************")


    def test_delete_presence(self):
        self.logger.info("*********************Test_002_04_Delete button visibility**********************")
        self.logger.info(
            "****************Verify whether delete button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_delete = self.driver.find_element(By.XPATH, "//button[@type='submit' and text()='Delete']")
        if ele_delete.is_displayed() and ele_delete.is_enabled():
            assert False
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "Delete_button_presence.png")
            assert True

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_04_Passed ***********************")



    def test_save_apply_presence(self):
        self.logger.info("*********************Test_002_05_Save and Apply button visibility***********************")
        self.logger.info(
            "****************Verify whether save and apply button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_save_apply = self.driver.find_element(By.XPATH, "//button[@type='submit' and text()='Save & Apply']")
        if ele_save_apply.is_displayed() and ele_save_apply.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "save_and_apply_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_05_Passed ***********************")



    def test_apply_presence(self):
        self.logger.info("*********************Test_002_06_Apply button visibility***********************")
        self.logger.info(
            "****************Verify whether Apply button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_apply = self.driver.find_element(By.XPATH, "//button[@type='submit' and text()='Apply']")
        if ele_apply.is_displayed() and ele_apply.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "apply_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_06_Passed ***********************")


    def test_clear_presence(self):
        self.logger.info("*********************Test_002_07_Clear button visibility***********************")
        self.logger.info(
            "****************Verify whether Clear button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_clear = self.driver.find_element(By.XPATH, "//button[@type='button' and text()='Clear']")
        if ele_clear.is_displayed() and ele_clear.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "clear_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_07_Passed ***********************")



    def test_close_presence(self):
        self.logger.info("*********************TTest_002_08_Close button visibility***********************")
        self.logger.info(
            "****************Verify whether Close button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.more_filter()
        time.sleep(3)
        ele_close = self.driver.find_element(By.XPATH, "//button[@type='button' and text()='Close']")
        if ele_close.is_displayed() and ele_close.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "close_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_08_Passed ***********************")


    @pytest.mark.sanity
    def test_Ticket_close_presence(self):
        self.logger.info("*********************TTest_002_09_Close button visibility***********************")
        self.logger.info(
            "****************Verify whether Close button is available and is enabled when clicked on More filters ******************")
        self.login_obj = LoginPage(self.driver)
        self.logout_obj = LogoutPage(self.driver)
        self.Alarm_obj = AlarmAlert(self.driver)
        self.login_obj.eots_login(self.mail_id, self.password)
        self.Alarm_obj.alarm_alert_click()
        time.sleep(2)
        self.Alarm_obj.checkbox()
        time.sleep(1)
        self.Alarm_obj.create_tickets()
        time.sleep(3)
        target = self.driver.find_element(By.XPATH,"//*[@id='logticketlist']/tr[10]")
        self.driver.execute_script('arguments[0].scrollIntoView(true);',target)
        ele_close = self.driver.find_element(By.XPATH,"/html/body/div[9]/div[3]/div/button[1]")
        if ele_close.is_displayed() and ele_close.is_enabled():
            assert True
        else:
            self.driver.save_screenshot(".\\Screenshots\\" + "close_button_presence.png")
            assert False

        self.logout_obj.eots_logout("yes")
        self.logger.info("********************* Test_002_09_Passed ***********************")
Exemplo n.º 25
0
class Test_001_login:
    baseUrl = ReadConfig.getApplicationURL()
    username = ReadConfig.getUserName()
    password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    @pytest.mark.regression
    def test_homePageTitle(self, setUp):

        self.logger.info(
            "*********************Test_Login_1**********************************"
        )
        self.logger.info(
            "*********************Verifying_Login_Page_Title**********************************"
        )
        self.driver = setUp
        self.driver.get(self.baseUrl)
        act_title = self.driver.title
        if act_title == "Your store. Login":
            self.logger.info(
                "*********************LoginPage_Title_Test_Passed**********************************"
            )
            assert True
            self.driver.close()
        else:
            self.logger.info(
                "*********************LoginPage_Title_Tst_Failed**********************************"
            )
            self.driver.save_screenshot("loginPage.png")
            self.driver.close()
            assert False

    @pytest.mark.sanity
    @pytest.mark.regression
    def test_login(self, setUp):

        self.logger.info(
            "*********************Test_Login_2**********************************"
        )
        self.logger.info(
            "*********************Verifying_Home_Page_Title**********************************"
        )
        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()
        act_titile = self.driver.title
        if act_titile == "Dashboard / nopCommerce administration":
            self.logger.info(
                "*********************HomePage_Title_Test_Passed**********************************"
            )
            assert True
            self.driver.close()
        else:
            self.driver.save_screenshot("..//Reorts/Screen.png")
            self.logger.info(
                "*********************HomePage_Title_Test_Failed**********************************"
            )
            self.driver.close()
            assert False
Exemplo n.º 26
0
class UIHelper():
    # UI Helper class
    logger = LogGen.loggen()
    explicit_wait = float(ReadConfig.getexplicitwait())

    def __init__(self,driver):
        self.driver=driver
        self.locator_strategies = ['XPATH', 'ID', 'NAME', 'CLASS_NAME', 'LINK_TEXT',
                                   'CSS_SELECTOR', 'PARTIAL_LINK_TEXT', 'TAG_NAME']


    def is_element_displayed(self, locator, explicit_wait=None):
        try:

            if explicit_wait is None:
                explicit_wait = self.explicit_wait

            if isinstance(locator, str):

                locator_details = locator.split('=', 1)
                element = WebDriverWait(self.driver, explicit_wait).until(
                    EC.visibility_of_element_located(
                        (self.get_locator_strategy(locator_details[0]), locator_details[1])))
                if element is not None:
                    return True
                else:
                    return False
            elif isinstance(locator, WebElement):
                return locator.is_displayed()
        except Exception as e:
            return False

    def click(self, locator, explicit_wait=None):
        try:
            self.get_clickable_web_element(locator, explicit_wait).click()
        except Exception as e:
            self.logger.info(e)
            raise


    def get_clickable_web_element(self, locator, explicit_wait=None):
        try:
            if explicit_wait is None:
                explicit_wait = self.explicit_wait

            if isinstance(locator, str):
                locator_details = locator.split('=', 1)

                return WebDriverWait(self.driver, explicit_wait).until(
                    EC.element_to_be_clickable((self.get_locator_strategy(locator_details[0]), locator_details[1])))

        except Exception as e:
            self.logger.info(e)
            raise


    def type(self, locator, text, pbool_clear=False, explicit_wait=None, pbool_click_before_type=True):
        """
        Description:
        |  This method will type the given value on the locator provided . It will find the element for the locator given , convert it into a web element then wait for it to be clickable , the time of wait will depend on the value passed in the explicit wait . It will then click on the element and finally type in the value

        :param locator: This parameter will contain the locator in a fixed format which is , locatortype=locator . For eg. id=username or xpath=.//*[@id='username']
        :type locator: String
        :param text: This parameter will contain the value to be typed into the web element
        :type text: String
        :param explicit_wait: This parameter will by default be none and the number passed in it would be the explicit wait(in seconds) for the particular element
        :type explicit_wait: Integer
        :param pbool_clear: This parameter is to use clear feature,if this is set to True respective field content will be cleared,By default this is set to False and pbool_clear only accepts to boolean value
        :type pbool_clear: Boolean
        :param pbool_click_before_type: This parameter is used to determine whether there will be a click on the element or not before typing the given text
        :type pbool_click_before_type: Boolean


        :return: None

        """
        try:
            if pbool_click_before_type:
                self.get_clickable_web_element(locator, explicit_wait).click()
            if pbool_clear:
                self.get_clickable_web_element(locator, explicit_wait).clear()
            self.get_clickable_web_element(locator, explicit_wait).send_keys(text)
        except Exception as e:
            self.logger.info(e)
            raise


    def get_locator_strategy(self, pstr_locator_strategy):
        """
        Description:
            |  this method returns the type of the locator, if pstr_locator_strategy is not in given strategies it returns an error

        :param pstr_locator_strategy: pstr_locator_strategy is the type of locator('XPATH', 'ID', 'NAME','CSS_SELECTOR', 'TAG_NAME', 'LINK_TEXT' and 'PARTIAL_LINK_TEXT')
        :type pstr_locator_strategy: String

        """
        try:
            if pstr_locator_strategy.upper() not in self.locator_strategies:
                raise Exception("Unsupported locator strategy - " + pstr_locator_strategy.upper() + "! " +
                                "Supported locator strategies are 'XPATH', 'ID', 'NAME', "
                                "'CSS_SELECTOR', 'TAG_NAME', 'LINK_TEXT' , 'CLASS_NAME' and 'PARTIAL_LINK_TEXT'")
            else:
                return getattr(By, pstr_locator_strategy.upper())
        except Exception as e:
                self.logger.info(e)
                raise




    def verify_url(self,pstr_old_url, pstr_current_url):
        try:
            if 'https' in pstr_current_url:
                pstr_current_url = pstr_current_url.replace('https://','')
            elif 'http' in pstr_current_url:
                pstr_current_url = pstr_current_url.replace('http://','')

            regex = "^[{]?[0-9a-fA-F]{8}" + "-([0-9a-fA-F]{4}-)" + "{3}[0-9a-fA-F]{12}[}]?$"
            p = re.compile(regex)
            if (re.search(p, pstr_current_url.split('/')[-1])):
                pstr_current_url = pstr_current_url.replace('/' + pstr_current_url.split('/')[-1], '')
            if pstr_current_url in pstr_old_url:
                self.logger.info("URL is correct")
                return True
            else:
                self.logger.info("URL is incorrect")
                return False
        except Exception as e:
            self.logger.info(e)
            raise

    def select_dropdown_value(self, plocator, **kwargs):
        """
        Description:
            |  this method is to used to select values from drop downs . Please note this method will work for elements with "select" tag
        :param plocator: plocator is the locator of the dropdown
        :type plocator: String

        Examples:
            |  select_dropdown_value(locator,visible_text='text')
            |  select_dropdown_value(locator,value='text')
            |  select_dropdown_value(locator,index=1)
        """
        try:
            select_web_element = Select(self.get_clickable_web_element(plocator))

            if "visible_text" in kwargs:
                select_web_element.select_by_visible_text(kwargs.get("visible_text"))
            elif "value" in kwargs:
                select_web_element.select_by_value(kwargs.get("value"))
            elif "index" in kwargs:
                select_web_element.select_by_index(kwargs.get("index"))
            else:
                raise Exception("No valid parameter passed")
        except Exception as e:
            self.logger.info(e)
            raise

    def wait_for_invisibility_web_element(self, locator, explicit_wait=None):
        """
           Description:
           |  This method will wait until the locator passed is invisible and return True or False based on wether th elemnet is invisible or not
           |  If the explicit wait time needs to be changed from the default wait time in configuration file, updated time can be passed in parameters which will work only for this element

           :param locator: This parameter will contain the locator in a fixed format which is , locatortype=locator . For eg. id=username or xpath=.//*[@id='username']
           :type locator: String - Locator can only be xpath/id/css/classname
           :param explicit_wait: This parameter will by default be the default explicit wait time in configuration file and the number passed in it would be the explicit wait(in seconds) for the particular element
           :type explicit_wait: Integer

           :return: WebElement

           Examples:

           .. notes::
               |  If no value is passed in for the explicit wait it will by use the default explicit wait from the configuration file
           """
        try:
            if explicit_wait is None:
                explicit_wait = self.explicit_wait

            locator_details = locator.split('=', 1)
            return WebDriverWait(self.driver, explicit_wait).until(
                EC.invisibility_of_element_located((self.get_locator_strategy(locator_details[0]), locator_details[1])))

        except Exception as e:
            self.logger.info(e)
            raise
class Test_Login_Page:
    faker = Faker()
    logger = LogGen.loggen()
    baseURL = environment.dev_url
    username = user.dev_agent
    password = password.dev_password
    loginpagetitle = page.dev_loginpage_title
    loggedinpagetitle = page.page_title
    resetpagetitle = "Reset Password"
    wrongemailpasswordmessage = LoginPage.text_wrong_email_or_password_message_xpath

    @pytest.mark.regression
    @allure.severity(allure.severity_level.NORMAL)
    @allure.description(
        "This test verifies user is able to login in and log out successfully")
    @allure.link('https://knowink.atlassian.net/browse/IT-135',
                 name='Jira(login)')
    @allure.link('https://knowink.atlassian.net/browse/IT-136',
                 name='Jira(logout)')
    @allure.link('https://knowinkdev.testrail.com/index.php?/cases/view/79210',
                 name='TestRail(login)')
    @allure.link('https://knowinkdev.testrail.com/index.php?/cases/view/79212',
                 name='TestRail(logout)')
    def test_login_logout(self, setup):
        self.logger.info("Starting test_login_logout")
        driver = setup
        driver.get(self.baseURL)
        lp = LoginPage(driver)
        lp.login()
        bp = BasePage(driver)
        bp.clickUserAvatar()
        bp.clickLogout()
        time.sleep(1)

        if driver.title == self.loginpagetitle:
            self.logger.info("test_login_logout Test: PASSED")
            assert True
        else:
            self.logger.error("test_login_logout Test: FAILED")
            allure.attach(driver.get_screenshot_as_png(),
                          name="test_login_logout",
                          attachment_type=AttachmentType.PNG)
            assert False
        driver.close()

    @pytest.mark.regression
    @allure.severity(allure.severity_level.NORMAL)
    @allure.description("This test verifies logins with bad credentials fail")
    @allure.link('https://knowink.atlassian.net/browse/IT-135', name='Jira')
    @allure.link('https://knowinkdev.testrail.com/index.php?/cases/view/79210',
                 name='TestRail ')
    def test_login_fail_scenarios(self, setup):
        self.logger.info("Starting test_login_fail_scenarios")
        driver = setup
        driver.get(self.baseURL)
        lp = LoginPage(driver)
        lp.setUsername(self.username)
        lp.setPassword("WrongPassword")
        lp.clickLogin()
        assert True if driver.title == self.loginpagetitle else False, allure.attach(
            driver.get_screenshot_as_png(),
            name="test_login_fail_scenarios_1",
            attachment_type=AttachmentType.PNG)
        assert self.wrongemailpasswordmessage

        lp.setUsername(self.faker.safe_email())
        lp.setPassword(self.password)
        lp.clickLogin()
        assert True if driver.title == self.loginpagetitle else False, allure.attach(
            driver.get_screenshot_as_png(),
            name="test_login_fail_scenrios_2",
            attachment_type=AttachmentType.PNG)
        assert self.wrongemailpasswordmessage

        lp.setUsername(self.faker.safe_email())
        lp.setPassword("WrongPassword")
        lp.clickLogin()
        assert True if driver.title == self.loginpagetitle else False, allure.attach(
            driver.get_screenshot_as_png(),
            name="test_login_fail_scenarios_3",
            attachment_type=AttachmentType.PNG)
        assert self.wrongemailpasswordmessage
        self.logger.info("test_login_fail_scenarios Test: PASSED")
        driver.close()

    @pytest.mark.regression
    @allure.severity(allure.severity_level.NORMAL)
    @allure.description(
        "This test verifies the user is able to use the forgot password feature"
    )
    @allure.link('https://knowink.atlassian.net/browse/IT-144', name='Jira')
    @allure.link('https://knowinkdev.testrail.com/index.php?/cases/view/98266',
                 name='TestRail ')
    def test_login_forgotpassword(self, setup):
        self.logger.info("test_login_forgotpassword")
        driver = setup
        driver.get(self.baseURL)
        lp = LoginPage(driver)
        lp.clickForgotPassword()
        lp.setForgotPasswordUserEmail(self.faker.safe_email())
        lp.clickForgotPasswordEmailContinueButton()
        time.sleep(.5)

        if driver.title == self.resetpagetitle:
            self.logger.info("test_login_forgotpassword Test: PASSED")
            assert True
        else:
            self.logger.error("test_login_forgotpassword Test: FAILED")
            allure.attach(driver.get_screenshot_as_png(),
                          name="test_login_forgotpassword",
                          attachment_type=AttachmentType.PNG)
            assert False
        self.logger.info("**** Completed Test_Login_Page ****")
        driver.close()
Exemplo n.º 28
0
class Test_001_Login:
    # Here instead of hard coding the values into the following 3 class variables
    # we are getting their values from the static methods of the "ReadConfig" class
    # present in the readProperties file

    baseURL = ReadConfig.getApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()

    logger = LogGen.loggen()

    # Now we will write 2 test methods in this class
    # For verifying the login functionality
    # For verifying the "Home Page Title" text
    # Here self.driver refers to the class variable "driver"

    # Here to avoid writing of driver initialization code like "self.driver=webdriver.Chrome()"
    # in each and every test method we have utilised setup() fixture and we have made the
    # test method "test_homePageTitle" receive the setup() fixture as an argument and
    # make the self.driver class variable receive that fixture like self.driver=setup
    # Here the setup() fixture will return the driver and that driver will be assigned to self.driver eventually

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

        self.driver = setup
        self.driver.get(self.baseURL)
        actual_title = self.driver.title
        print(actual_title)
        # Here if the title matches assertion of True will happen ( Passing of test case ) and finally driver will be closed.
        # For failing the test try giving a wrong title text like "Your store. Login123" and see that a error screenshot
        # will be captured.
        if actual_title == "Your store. Login":
            assert True
            self.driver.close()
            self.logger.info(
                "************** Home Page Title test is passed **********")
        else:
            # Here if the title doesnt match, screenshot of failure will be taken and then driver will be closed
            # and finally assertion of False will happen ( Failing the test case )
            self.driver.save_screenshot(".\\Screenshots\\" +
                                        "test_homePageTitle.png")
            self.driver.close()
            self.logger.error(
                "************** Home Page Title test is failed **********")
            assert False

    # Here to avoid writing of driver initialization code like "self.driver=webdriver.Chrome()"
    # in each and every test method we have utilised setup() fixture and we have made the
    # test method "test_login" receive the setup() fixture as an argument and
    # make the self.driver class variable receive that fixture like self.driver=setup
    # Here the setup() fixture will return the driver and that driver will be assigned to self.driver eventually

    # Normal login comes under both sanity and regression
    @pytest.mark.sanity
    @pytest.mark.regression
    def test_login(self, setup):
        self.logger.info(
            "************** Verifying Login Page Title **********")

        # Here self.driver refers to the class variable "driver"
        self.driver = setup

        # Since all the variables used here like "username","password"
        # and "baseURL" are class variables they have to be referenced
        # like "self.class_variable_name"

        self.driver.get(self.baseURL)
        # Here to access the action methods of the LoginPage class
        # we have to create object of that class and access through it.
        # Here since object "lp" is used in this class we have to
        # refer it using self as always

        # Now whenever we call the LoginPage class , the constructor
        # of it ( i.e LoginPage class) which is "__init__(self,driver)"
        # will be automatically invoked.
        # But this constructor is expecting a driver as a parameter
        # and so we will pass "self.driver" as parameter

        self.lp = LoginPage(self.driver)

        # Now after creating the object of the "LoginPage" class
        # we can invoke the action methods present in that class
        # using the convention "self.lp.action_method_name"
        # Since all the variables used here like "username","password"
        # and "baseURL" are class variables they have to be referenced
        # like "self.class_variable_name"

        self.lp.setUserName(self.username)

        self.lp.setPassword(self.password)

        self.lp.clickLogin()

        act_title = self.driver.title
        print(act_title)

        # Now we have to validate the successful login in the Login Page
        # Here if the title matches assertion of True will happen ( Passing of test case ) and finally driver will be closed.
        # For failing the test try giving a wrong title text like "Dashboard / nopCommerce administration123"
        # and see that a error screenshot will be captured.

        if act_title == "Dashboard / nopCommerce administration":
            assert True
            self.logger.info("************** Login test passed **********")
            self.driver.close()

        else:
            # Here if the title doesnt match, screenshot of failure will be taken and then driver will be closed
            # and finally assertion of False will happen ( Failing the test case )
            self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png")
            self.driver.close()
            self.logger.error("************** Login test failed **********")
            assert False
Exemplo n.º 29
0
class Test003Addcustomer:
    baseURL = ReadConfig.readApplicationURL()
    username = ReadConfig.getUseremail()
    password = ReadConfig.getPassword()
    logger = LogGen.loggen()  # create logger object

    def test_addCustomer(self):
        self.logger.info(
            "**************test003  add customer  Login started*****")
        self.driver = webdriver.Chrome("C:\Program Files\chromedriver.exe")
        self.driver.get(self.baseURL)
        self.driver.maximize_window()
        # login data is passed using the login page class object lp
        self.lp = LogInPage(self.driver)
        self.lp.setUserName(self.username)
        self.lp.setPassword(self.password)
        self.lp.clickLogIn()
        self.logger.info("************test 003: login successfull************")
        self.logger.info(
            "******** Now adding new customer test started ***************")
        # adding customer information after the successful login
        self.addcust = AddCustomer(self.driver)
        self.addcust.clickOnCustomerMenu()
        self.addcust.clickOnCustomerMenuItem()
        self.addcust.addNew()
        self.logger.info("****** adding customer details*************")

        # generate a random gmail for each customer
        # 8 character string  in lowercase with digits
        def random_generator(size=8,
                             chars=string.ascii_lowercase + string.digits):
            # loop to generate each random character for gmail
            return ''.join(random.choice(chars) for x in range(size))

        self.email = random_generator()
        self.addcust.setCustomerEmail(self.email)
        self.addcust.setpassword("test123")
        self.addcust.setGender("Female")
        self.addcust.setFirstName("Maddie")
        self.addcust.setLastName("Gandra")
        self.addcust.setDob("07/01/1979")
        self.addcust.setCompanyname("AutomationQA")
        self.addcust.setNewsLetter("My NOP commerce project")
        self.addcust.setAdminContent(" This is for testing")
        self.addcust.setCustomerRoles("Administrators")
        self.addcust.setManagerOfVendor("1")
        self.addcust.clickSave()

        self.logger.info(
            "************ saving customer information*****************")

        self.logger.info(
            "************* add customer validation started********")
        # a message about the customer added successfully is displayed on the body of page.so capture it
        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_scrnshot.png")
            self.logger.error(
                "*************** add customer  Test Failed *************")
            assert True == False
        self.driver.close()
        self.logger.info(
            " ******** Ending test003 Add customer test **************")
Exemplo n.º 30
0
class Test_002_Login:
    baseURL = ReadConfig.getApplicationURL()
    path = ".//TestData/LoginData.xlsx"
    logger = LogGen.loggen()


    @pytest.mark.regression
    def test_login_ddt(self, setup):
        self.logger.info(("**********************Test_002_Login***************"))
        self.logger.info("*****************verify login DDt test*********************")
        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = Login(self.driver)

        self.rows=XLUtils.getRowCount(self.path,'Sheet1')
        print("no.of rows in Excelsheet:",self.rows)
        list_status = []

        for r in range(2,self.rows+1):
            self.user=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.user)
            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 to login****************")
                    self.lp.clickLogout()
                    list_status.append("pass")

                elif self.exp =="Fail":
                    self.logger.info("******************failed to login***********************")
                    self.lp.clickLogout()
                    list_status.append("Fail")

            elif act_title != exp_title:

                if self.exp == "Pass":
                    self.logger.info("*****************failed*********************")

                    list_status.append("Fail")

                elif self.exp =="Fail":
                    self.logger.info("**************Passed*******************")

                    list_status.append("Pass")

        if "Fail" not in list_status:
            self.logger.info("*******************LoginDDT test Passed************")
            self.driver.close()
            assert True

        else:
            self.logger.info("****************LoginDDt Test failed********************")
            self.driver.close()
            assert False

        self.logger.info("***************End of Login DDT Test****************")
        self.logger.info("*************completed TC_Test_002_Login******************")