예제 #1
0
class Test_DDT_Login:
    baseURL = ReadConfig.getAppURL()  # using readProperties from utilities
    path = "..//TestData/Test_login.xlsx"

    log = LogGen.loggen()
    log.info('Start logs')

    def test_02_DDT_login(self, setup):

        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = Login(self.driver)

        self.rows = ExcelUtil.getRowCount(self.path, "Sheet1")
        print("total rows", self.rows)

        lst_status = []

        for r in range(2, self.rows+1):

            self.username = ExcelUtil.readData(self.path, "Sheet1", r, 1)
            self.password = ExcelUtil.readData(self.path, "Sheet1", r, 2)
            self.exp = ExcelUtil.readData(self.path, "Sheet1", r, 3)

            self.lp.enterUsername(self.username)
            self.lp.enterPassword(self.password)
            self.lp.clickLogin()
            time.sleep(5)

            chk_login = self.driver.title
            if chk_login == "Dashboard / nopCommerce administration":
                if self.exp=='Pass':
                    self.lp.clickLogout()
                    lst_status.append("Pass")
                elif self.exp =='Fail':
                    self.lp.clickLogout()
                    lst_status.append("Failed")


                if chk_login != "Dashboard / nopCommerce administration":

                    if self.exp == 'Pass':

                        lst_status.append("Failed")
                    elif self.exp == 'Fail':

                        lst_status.append("Pass")

        if "Fail" not in lst_status:
            print("Test Success")
            ExcelUtil.writeData(self.path, "Sheet1", 6, 4, "Accepted")
            self.driver.close()

        else:
            print("Test Failed")
            ExcelUtil.writeData(self.path, "Sheet1", 6, 4, "Failed")
            self.driver.close()
class Test_001_Login:

    #baseURL = 'https://admin-demo.nopcommerce.com/'
    baseURL = ReadConfig.getAppURL() #using readProperties from utilities
    username = '******'
    password = '******'

    log = LogGen.loggen()
    log.info('Start logs')

    @pytest.mark.sanity
    def test_01_HomePageTitle(self):


        self.log.info("**** logs verified HomePage Title started ***")
        self.driver = webdriver.Chrome()
        print(self.baseURL)
        self.driver.get(self.baseURL)
        act_title = self.driver.title
        if act_title == "Your store. Login":
                assert True
                self.log.info("**** logs verified HomePage Title matched ***")
                self.driver.close()

        else:
                self.log.error("**** logs verified HomePage Title mismatched ***")
                self.driver.save_screenshot("..\\Screenshots\\HomePageTitle.png")
                self.driver.close()
                assert False


    @pytest.mark.regression
    def test_02_login(self, setup):
        self.driver = setup
        self.driver.get(self.baseURL)
        self.lp = Login(self.driver)
        self.lp.enterUsername(self.username)
        self.lp.enterPassword(self.password)
        self.lp.clickLogin()
        chk_login = self.driver.title
        if chk_login == "Dashboard / nopCommerce administration":
            
                assert True
                self.driver.close()

        else:
                self.driver.save_screenshot("..\\Screenshots\\test_02_login.png")
                self.driver.close()
                assert False

    """def test_03_login(self, setup): #using pytest fixture >> setup
from selenium import webdriver
from pageObjects.LoginPage import Login
from utilities.customLogger import LogGen

driver = webdriver.Chrome()
driver.maximize_window()

driver.get('https://admin-demo.nopcommerce.com/')

log = LogGen.loggen()
print(log)
log.info("test started")

lgn = Login(driver)
lgn.enterUsername('*****@*****.**')
lgn.enterPassword('admin')
lgn.clickLogin()
driver.save_screenshot("C:\\Users\\dell\\Pictures\\Screenshots\\ss.png")
act = lgn.driver.title  #imp to use the method.driver from imported class else no output
print(act)
driver.close()
if act == 'Dashboard / nopCommerce administration':
    assert True

else:
    assert False