class TestStatus(SeleniumDriver):
    log = cl.customLogger(logging.INFO)

    def __init__(self, driver):
        super(TestStatus, self).__init__(driver)
        self.resultList = []

    def setResult(self, result, resultMessage):
        try:
            if result is not None:
                if result == 'FAIL':
                    self.resultList.append("FAIL")
                    self.log.info("### VERIFICATION FAILED :: + " +
                                  resultMessage)
                    self.screenShot(resultMessage)
                elif not any("FAIL" in lis for lis in result):
                    self.resultList.append("PASS")
                    self.log.info("### VERIFICATION SUCCESSFUL :: + " +
                                  resultMessage)
                elif result == 'PASS':
                    self.resultList.append("PASS")
                    self.log.info("### VERIFICATION SUCCESSFUL :: + " +
                                  resultMessage)
                else:
                    self.resultList.append("FAIL")
                    self.log.info("### VERIFICATION FAILED :: + " +
                                  resultMessage)
                    self.screenShot(resultMessage)
            else:
                self.resultList.append("FAIL")
                self.log.error("### VERIFICATION FAILED :: + " + resultMessage)
                self.screenShot(resultMessage)
        except:
            self.resultList.append("FAIL")
            self.screenShot(resultMessage)
            self.log.error("### EXCEPTION OCCURRED !!!")

    def mark(self, result, resultMessage):
        self.setResult(result, resultMessage)

    def markFinal(self, testName, result, resultMessage):
        self.setResult(result, resultMessage)
        if any("FAIL" in lis for lis in self.resultList):
            self.log.error(testName + " ### TEST FAILED")
            self.resultList.clear()
            assert True == False
        else:
            self.log.info(testName + " ### TEST SUCCESSFUL")
            self.resultList.clear()
            assert True == True
Ejemplo n.º 2
0
class Util(object):

    log = cl.customLogger(logging.INFO)

    def sleep(self, sec, info=""):
        """
        Put the program to wait for the specified amount of time
        """
        if info is not None:
            self.log.info("Wait :: '" + str(sec) + "' seconds for " + info)
        try:
            time.sleep(sec)
        except InterruptedError:
            traceback.print_stack()
class newResourceTest(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self,oneTimeSetUp):
        self.rp = ResourcePage(self.driver)
        self.ts = TestStatus(self.driver)

    @pytest.mark.run(order=1)
    def test_newResource(self):
        self.log.info("#"*20)
        self.log.info("testcase for new Resources started")
        self.log.info("#" * 20)
        self.rp.resourceCreate()
class ForgotPasswordTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.forgot = ForgotPasswordPage(self.driver)
        self.lp = LoginPage(self.driver)
        self.ts = Status(self.driver)

    # @pytest.mark.run(order=2)
    def test_t9valid_email_ForgotPassword(self):
        self.log.info("test_t9valid_email_ForgotPassword success")
        self.forgot.forgotpasswordLoginPageButton()
        forgot_password_page_title_result = self.forgot.verifyForgotPasswordPageTitle(
        )
        self.ts.mark(forgot_password_page_title_result,
                     "Forgot Password Page Verification")
        self.forgot.forgotPassword("*****@*****.**")
        forgot_password_success_result = self.forgot.successForgotPassword()
        self.ts.markFinal("test_t9valid_email_ForgotPassword",
                          forgot_password_success_result,
                          "Forgot Password success verification")

    # @pytest.mark.run(order=1)
    def test_t10invalid_email_ForgotPassword(self):
        self.log.info("test_t10invalid_email_ForgotPassword started")
        self.forgot.forgotpasswordLoginPageButton()
        forgot_password_page_title_result = self.forgot.verifyForgotPasswordPageTitle(
        )
        self.ts.mark(forgot_password_page_title_result,
                     "Forgot password Page Verification")
        self.forgot.forgotPassword("quality")
        time.sleep(2)
        invalid_email_message = self.forgot.invalidEmail()
        self.ts.markFinal("test_t10invalid_email_ForgotPassword",
                          invalid_email_message,
                          "invalid email message verification")

    def test_t11back_to_login_page(self):
        self.log.info("test_t11back_to_login_page")
        self.forgot.forgotpasswordLoginPageButton()
        forgot_password_page_title_result = self.forgot.verifyForgotPasswordPageTitle(
        )
        self.ts.mark(forgot_password_page_title_result,
                     "Forgot password Page Verification")
        self.forgot.backtologin()
        time.sleep(2)
        login_page_title = self.lp.verifyLoginPageTitle()
        self.ts.markFinal("test_t11back_to_login_page", login_page_title,
                          "Back to login Page verification")
Ejemplo n.º 5
0
class SignInPage(SeleniumDriver):
    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # TEST ACCOUNT
    email = "*****@*****.**"
    password = "******"

    # LOCATORS
    _sign_in_link = "//a[contains(text(),'Sign in')]"  # xpath
    _login_email = "#email"  # css
    _login_pass = "******"  # css
    _login_button = "//button[@id='SubmitLogin']"  # xpath
    _user_order_history = "//span[contains(text(),'Order history and details')]"  # xpath
    _sign_out_link = "Sign out"  # link

    # ACTIONS WITH PAGE OBJECTS

    def clickSignInLink(self):
        self.elementClick(self._sign_in_link, "xpath")

    def verifySignInPageIsLoaded(self):
        page_title = self.getTitle()
        if page_title == "Login - My Store":
            return True
        else:
            return False

    def enterLoginEmail(self):
        self.sendKeys(self.email, self._login_email, "css")

    def enterLoginPassword(self):
        self.sendKeys(self.password, self._login_pass, "css")

    def clickLoginButton(self):
        self.elementClick(self._login_button, "xpath")

    def verifySuccessfulLogin(self):
        result = self.isElementPresent(self._user_order_history, "xpath")
        return result

    def logOut(self):
        self.elementClick(self._sign_out_link, "link")

    def verifySuccessfulLogOut(self):
        result = self.isElementPresent(self._sign_in_link, "xpath")
        return result
Ejemplo n.º 6
0
class StatusVerify(SeleniumDriver):
    log = cl.customLogger(logging.INFO)

    def __init__(self, driver):
        """
        Inits CheckPoint class
        """
        super(StatusVerify, self).__init__(driver)
        self.resultList = []

    def setResult(self, result, resultMessage):
        try:
            if result == True:
                self.resultList.append("PASS")
                self.log.info("### VERIFICATION SUCCESSFUL :: + " +
                              resultMessage)
            else:
                self.resultList.append("FAIL")
                self.log.error("### VERIFICATION FAILED :: + " + resultMessage)
                self.screenShot(resultMessage)
        except:
            self.resultList.append("FAIL")
            self.log.error("### Exception Occurred !!!")
            self.screenShot(resultMessage)
            print_stack()

    def mark(self, result, resultMessage):
        """
        Mark the result of the verification point in a test case
        """
        self.setResult(result, resultMessage)

    def markFinal(self, testName, result, resultMessage):
        """
        Mark the final result of the verification point in a test case
        This needs to be called at least once in a test case
        This should be final test status of the test case
        """
        self.setResult(result, resultMessage)

        print self.resultList

        if "FAIL" in self.resultList:
            self.log.error(testName + " ### TEST FAILED")
            del self.resultList[:]
            assert False
        else:
            self.log.info(testName + " ### TEST SUCCESSFUL")
            del self.resultList[:]
            assert True
Ejemplo n.º 7
0
class CheckStatus(SeleniumDriver):

    log = cl.customLogger(logging.INFO)

    def __init__(self, driver):
        '''
        inits checkpoint class
        '''
        super(CheckStatus, self).__init__(driver)
        self.resultList = []

    def setResult(self, result, resultMessage):
        try:
            if result is not None:
                if result == True:
                    self.resultList.append("PASS")
                    self.log.info('### VERIFICATION SUCCESSFULL :: + '+ resultMessage)
                else:
                    self.resultList.append("FAIL")
                    self.log.error('### VERIFICATION FAILED :: + ' + resultMessage)
                    self.screenShot(resultMessage)
            if result is None:
                self.resultList.append("FAIL")
                self.log.error('### VERIFICATION FAILED :: + ' + resultMessage)
                self.screenShot(resultMessage)
        except:
            self.resultList.append("FAIL")
            self.log.error('### EXCEPTION OCCURRED!!!')
            self.screenShot(resultMessage)

    def mark(self, result, resultMessage):
        '''
        Mark the result of the verification point in a test case
        '''
        self.setResult(result, resultMessage)

    def markFinal(self, testName, result, resultMessage):
        '''
        mark the final result of the verification point in a test case
        use it at least once, as a final status of test case
        '''
        self.setResult(result, resultMessage)
        if "FAIL" in self.resultList:
            self.log.error(testName +" ### TEST FAILED")
            self.resultList.clear()
            assert True == False
        else:
            self.log.info(testName + " ### TEST SUCCESSFULL")
            self.resultList.clear()
            assert True == True
Ejemplo n.º 8
0
class TestStatus(SeleniumDriver):
    log = cl.customLogger(logging.INFO)

    def __init__(self, driver):
        super(TestStatus, self).__init__(driver)
        self.resultList = []

    def setResult(self, result, resultMessage):
        try:
            if result is not None:
                if result:
                    self.resultList.append("PASS")
                    self.log.info(F'VERIFICATION SUCCESSFUL {resultMessage}')
                else:
                    self.resultList.append("FAIL")
                    self.log.error(f'VERIFICATION FAILED {resultMessage}')
                    self.screenShot(resultMessage)
            else:
                self.resultList.append("FAIL")
                self.log.error(f'VERIFICATION FAILED {resultMessage}')
                self.screenShot(resultMessage)
        except:
            self.resultList.append("FAIL")
            self.log.error("Exception occurred!!!")
            self.screenShot(resultMessage)
            print_stack()

    def mark(self, result, resultMessage):
        """
        Mark the result of the verification point in a test case
        """
        self.setResult(result, resultMessage)

    def markFinal(self, testName, result, resultMessage):
        """
        Mark the final result of the verification point in a test case
        This needs to be called at least once in a test case
        This should be final test status of the test case
        """
        self.setResult(result, resultMessage)

        if "FAIL" in self.resultList:
            self.log.error(f'testName {"TEST FAILED"}')
            self.resultList.clear()
            assert True == False
        else:
            self.log.info(f'testNAME {"TEST SUCCESSFUL"}')
            self.resultList.clear()
            assert True == True
Ejemplo n.º 9
0
class addPeople(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)
    '''@pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        #self.ap = AddPeople(self.driver)
        self.ts = TestStatus(self.driver)'''
    @pytest.mark.run(order=1)
    def test_01addNewPeople(self):
        self.ap = AddPeople(self.driver)
        self.ts = TestStatus(self.driver)
        self.log.info("*#" * 20)
        self.log.info("People adding started")
        self.log.info("*#" * 20)
        email = self.ap.util.getUniqueName()
        result = self.ap.verifyNewPeopleAdded(email + "@gmail.com")
        print("Result1: " + str(result))
        #assert result == True
        #self.ts.markFinal("test_addNewPeople", result, "People added successfully")

    #@pytest.mark.run(order=2)
    #def test_verifyPeopleAdded(self):
    #self.log.info("*#" * 20)
    #self.log.info("People added text verification started")
    #self.log.info("*#" * 20)
    #email = self.ap.util.getUniqueName()
    #result = self.ap.verifyNewPeopleAddedText(email + "@gmail.com")

    @pytest.mark.run(order=2)
    def test_02addAlreadyAddedPeople(self):
        self.ts = TestStatus(self.driver)
        self.ap = AddPeople(self.driver)
        self.log.info("*#" * 20)
        self.log.info("Select already added people started")
        self.log.info("*#" * 20)
        self.ap.addAlreadyAddedPeople()

    #@pytest.mark.run(order=4)
    #def test_verifyAlreadyAddedPeople(self):
    #self.log.info("*#" * 20)
    #self.log.info("Verify already added People text")
    #self.log.info("*#" * 20)
    #result = self.ap.verifyAddedPeopleText()
    #assert result == True
    #self.ts.markFinal("test_verifyAlreadyAddedPeople", result, "Already added people text verified")

    def test_03SelectFilterFromDropdown(self):
        self.ap = AddPeople(self.driver)
        self.ts = TestStatus(self.driver)
        self.ap.filterFunctionality()
Ejemplo n.º 10
0
class LoginPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    # Locators
    _login_link = "//a[contains(.,'Sign In')]"
    _email_field = "email"
    _password_field = "password"
    _login_button = "//input[@type='submit']"

    def clickLoginLink(self):
        self.elementClick(self._login_link, locatorType="xpath")

    def enterEmail(self, email):
        self.sendKeys(email, self._email_field)

    def enterPassword(self, password):
        self.sendKeys(password, self._password_field)

    def clickLoginButton(self):
        self.elementClick(self._login_button, locatorType="xpath")

    def login(self, email="", password=""):
        self.clickLoginLink()
        self.enterEmail(email)
        self.enterPassword(password)
        self.clickLoginButton()

    def verifyLoginSuccessful(self):
        result = self.isElementPresent("//img[@class='zl-navbar-rhs-img ']",
                                       locatorType="xpath")
        return result

    def verifyLoginFailed(self):
        result = self.isElementPresent(
            "//span[@class='dynamic-text help-block']", locatorType="xpath")
        return result

    def verifyLoginTitle(self):
        return self.verifyPageTitle("All Courses")

    def logout(self):
        self.nav.navigateToSettings()
        self.elementClick(locator="//a[@href='/logout']", locatorType='xpath')
Ejemplo n.º 11
0
class LoginPage(SeleniumDriver):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators
    _login_link = "Login"
    _email_field = "user_email"
    _password_field = "user_password"
    _login_button = "commit"

    def clickLoginLink(self):
        self.elementClick(self._login_link, locatorType="link")

    def enterEmail(self, email):
        self.sendKeys(email, self._email_field)

    def enterPassword(self, password):
        self.sendKeys(password, self._password_field)

    def clickLoginButton(self):
        self.elementClick(self._login_button, locatorType="name")

    def login(self, email="", password=""):
        self.clickLoginLink()
        self.enterEmail(email)
        self.enterPassword(password)
        self.clickLoginButton()

    def verifyLoginSuccessful(self):
        result = self.isElementPresent(
            "//*[@id='navbar']//span[text()='User Settings']",
            locatorType="xpath")
        return result

    def verifyLoginFailed(self):
        result = self.isElementPresent(
            "//div[contains(text(),'Invalid email or password')]",
            locatorType="xpath")
        return result

    def verifyTitle(self):
        if "Google" in self.getTitle():
            return True
        else:
            return False
class Testcase_102_VerifyCheckOutError(unittest.TestCase):

    log = cl.customLogger(logging.DEBUG)

    @pytest.mark.run(order=1)
    @data(("seattletester", "Seattle123"))  # provide test data directly
    # @data(*getCSVData("../testdata/testdata.csv"))  # read test data from CSV file
    # @data(*getExcelData("test_TC01_verifylogin_Success"))  # read test data from Excel file
    # @data(*getlogindata())  # read test data from 'read_data.py'
    @unpack
    def test_TC02_verifyCheckoutError(self, userID, password):
        lp = login_page(self.driver)
        sh = searchHotel_page(self.driver)

        self.log.info("#" * 40)
        self.log.info("'test_TC02_verifyCheckoutError' started.")
        self.log.info("#" * 40)

        self.log.info("Log in to Hotel app.")
        lp.login(userID, password)

        result = sh.verifyLoginSuccessful()
        if result:
            self.log.info("### VERIFICATION SUCCESSFUL :: Login.")
        else:
            self.log.error("### VERIFICATION FAILED :: Login.")
        sleep(1)

        self.log.info("Input data in Search Hotel Page.")
        sh.inputSearchPageData("Sydney", "Hotel Creek", "Standard", "1 - One",
                               "12/20/2020", "12/15/2020", "1 - One",
                               "1 - One")
        sleep(1)

        self.log.info("Click Search button.")
        sh.clickSearchButton()
        sleep(1)

        result = sh.verifyCheckInDateFailed()
        if result:
            self.log.info(
                "### VERIFICATION SUCCESSFUL :: Check in date error message.")
        else:
            self.log.error(
                "### VERIFICATION FAILED :: Check in date error message.")

        self.log.info("#" * 40)
        self.log.info("'test_TC02_verifyCheckoutError' completed.")
        self.log.info("#" * 40)
Ejemplo n.º 13
0
class LoginPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # locators
    _welcome_webadmin_field = 'WelcomePage_webadmin'
    _username_field = 'username'
    _password_field = 'password'
    _submit_btn = '//button[@type="submit"]'


    def clickWelcomeAdminField(self):
        self.elementClick(self._welcome_webadmin_field)

    def enterUsernameField(self, username):
        self.sendKeys(username, self._username_field)

    def enterPasswordField(self, password):
        self.sendKeys(password, self._password_field)

    def clickSubmitButton(self):
        self.elementClick(self._submit_btn, locatorType='xpath')


    def login(self, username='', password=''):
        self.enterPasswordField(password)
        self.enterUsernameField(username)
        self.clickSubmitButton()

    def verifyLoginSuccesfull(self):
        # self.assertIn('Red Hat Virtualization Manager Web Administration', self.driver.title, 'Title is not as expected')
        element = self.waitForElement('id-compute', timeout=30)
        return element is not None

    def verifyLoginFailed(self):
        # TODO: convert this to text inside the message
        result = self.isElementPresent("//div[@class='alert alert-warning alert-dismissable']", 'xpath')
        return result

    def verifyTitle(self):
        return self.verifyPageTitle('Red Hat Virtualization Manager Web Administration')

    def hover_over_login(self):
        element_to_hover = self.getElement(self._submit_btn, locatorType='xpath')
        ActionChains(self.driver).move_to_element(element_to_hover).perform()
Ejemplo n.º 14
0
class Login_page(BasePage):
    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = Navigation_page(driver)

    #Locators
    _login_link = "Login"
    _email_field  = "user_email"
    _password_field = "user_password"
    _login_button = "commit"


    def clickLoginLink(self):
        self.elementClick(self._login_link,locatorType="link")

    def EnterEmail(self, email):
        self.sendKeys(email, self._email_field)

    def EnterPassword(self, password):
        self.sendKeys(password, self._password_field)
        time.sleep(2)
    def clickLoginbutton(self):
        self.elementClick(self._login_button,locatorType="name")

    def login(self, email="", password=""):

        self.clickLoginLink()
        self.EnterEmail(email)
        self.EnterPassword(password)
        self.clickLoginbutton()
        time.sleep(2)
    def verifyLoginSuccess(self):
        result = self.isElementPresent("//*[@id='navbar']//a[@href='/current_user/profile']",
                                       locatorType="xpath")
        return result
    def verifyLoginFail(self):
        result = self.isElementPresent("//div[contains(text(),'Invalid email or password')]",
                                       locatorType="xpath")
        return result

    def verifyLoginTitle(self):
        return self.verifyPageTitle("Let's Kode It")

    def logout(self):
        self.nav.navigateToUserSettings()
        self.elementClick(locator="//a[@href='/sign_out']", locatorType="xpath")
Ejemplo n.º 15
0
class BrokerTest(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.broker = BrokerPages(self.driver)

    def test_01VerifyClickingBrokerSectionOpensBrokerModal(self):
        self.log.info("*#" * 20)
        self.log.info(" test_01VerifyClickingBrokerSectionOpensBrokerModal ")
        self.log.info("*#" * 20)
        self.broker.ClickingBrokerSectionOpensBrokerModal()

    def test_02VerifyDealDetailsPageHasEmptyBrokerSection(self):
        self.log.info("*#" * 20)
        self.log.info(" test_02VerifyDealDetailsPageHasEmptyBrokerSection ")
        self.log.info("*#" * 20)
        self.broker.DealDetailsPageHasEmptyBrokerSection()

    # def test_03VerifyDealDetailsPageHasNotApplicableBrokerSection(self):
    #     self.log.info("*#" * 20)
    #     self.log.info(" test_03VerifyDealDetailsPageHasNotApplicableBrokerSection ")
    #     self.log.info("*#" * 20)
    #     self.broker.DealDetailsPageHasNotApplicableBrokerSection()

    def test_04VerifySubmitButtonShouldBeDisabled(self):
        self.log.info("*#" * 20)
        self.log.info(" test_04VerifySubmitButtonShouldBeDisabled ")
        self.log.info("*#" * 20)
        result = self.broker.SubmitButtonShouldBeDisabled()
        return result == True

    def test_05VerifyUserCanSearchAndCreateABroker(self):
        self.log.info("*#" * 20)
        self.log.info(" test_05VerifyUserCanSearchAndCreateABroker ")
        self.log.info("*#" * 20)
        self.broker.UserCanSearchAndCreateABroker()

    def test_06VerifyUserCanEditContacts(self):
        self.log.info("*#" * 20)
        self.log.info(" test_06VerifyUserCanEditContacts ")
        self.log.info("*#" * 20)
        self.broker.UserCanEditContacts()

    def test_07VerifyUserCanCreateANewContact(self):
        self.log.info("*#" * 20)
        self.log.info(" test_07VerifyUserCanCreateANewContact ")
        self.log.info("*#" * 20)
        self.broker.UserCanCreateANewContact()
Ejemplo n.º 16
0
class P01SearchGitHubCromox1(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators Google
    # _search_area = "//*[@title='Search']"
    # _search_area_type = 'xpath'
    _search_area = 'q'
    _search_area_type = 'name'
    _search_data = "github cromox1"

    # Google page
    def gotoSearchArea(self):
        self.elementClick(self._search_area,
                          locatorType=self._search_area_type)

    def searchGitHubCromox1(self):
        self.sendKeys(self._search_data,
                      self._search_area,
                      locatorType=self._search_area_type)
        self.sendKeys(Keys.ENTER,
                      self._search_area,
                      locatorType=self._search_area_type)

    def gotoGitHubCromox1(self):
        containtext = "//*[contains(text(),'cromox1 (Rosli Talib) · GitHub')]"
        cromox1_txt = 'cromox1 (Rosli Talib) · GitHub'

        element = self.getElementList(containtext, locatorType='xpath')
        count_cromox1 = len([x for x in element])
        print('Number GITHUB LINK = ' + str(count_cromox1))
        if count_cromox1 >= 1:
            element[0].click()
            cromox1_url = self.returnCurrentURL()
            print('CURRENT URL = ' + self.returnCurrentURL())
        else:
            # cromox1_url = self.base_url
            print('NO cromox1 GITHUB found')

    ## General
    def returnCurrentURL(self):
        return self.driver.current_url

    def gotosite(self, URL):
        return self.driver.get(URL)
Ejemplo n.º 17
0
class NavigationPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators
    _flights_tab = "tab-flight-tab-hp"
    _roundtrip_subTab = "flight-type-roundtrip-label-hp-flight"  #"gcw-packages-form-hp-package" or "flight-type-roundtrip-label"

    def bookRoundTrip(self):
        self.clickElement(self._flights_tab)
        self.clickElement(self._roundtrip_subTab)
Ejemplo n.º 18
0
class DatabaseConnection:

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, section):
        self.params = config(section=section)
        self.dm = DateTimeMan()

    def connection(self):
        try:
            # connect to the PostgreSQL server
            self.log.info("Connecting to the PostgreSQL database...")
            return psycopg2.connect(**self.params)
        except (Exception, psycopg2.DatabaseError) as error:
            self.log.critical(error)
Ejemplo n.º 19
0
class ToolbarNav(BasePage):
    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    _issuelnk = "//span[contains(text(),'Issues')]"
    _i_create = "//a[@class='btn btn-primary']"

    def clickIssue(self):
        self.elementClick(locator=self._issuelnk, locatorType="xpath")

    def clickIssueButton(self):
        self.elementClick(locator=self._i_create, locatorType="xpath")
Ejemplo n.º 20
0
class ViewRoom(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def ObjectSetup(self):
        self.room = ViewByRoom(self.driver)

    def test_01VerifyRoomCountFromViewByRoom(self):
        self.room.AllRoomCount()

    def test_02VerifyAddProductRoomInViewRoomWithoutAssignProduct(self):
        self.room.ProductAddInRoom()

    def test_03VerifyCancelButtonInViewRoomWithoutAssignProduct(self):
        self.room.ProductRoomCancelButton()

    def test_04VerifyCloseButtonInViewRoomWithoutAssignProduct(self):
        self.room.ProductRoomCloseButton()

    def test_05VerifySearchProductWithProductNameInViewRoomWithoutAssignProduct(self):
        self.room.SearchProductUsingProductName()

    def test_06VerifyClickOnProductNameNavigation(self):
        self.room.ClickProductName()

    def test_07VerifyIrrelevantSearchInViewRoomWithoutAssignProduct(self):
        self.room.IrrelevantProductNameSearch()

    def test_08VerifyEditExistingTabEmptyMessage(self):
        self.room.EmptyMessageOnEditExistingTab()

    def test_09VerifySelectViewRoomWithProducts(self):
        self.room.SelectViewRoomWithProduct()

    def test_10VerifyProductQuantityByIncreasing(self):
        self.room.quantityIncrease()

    def test_11VerifyProductQuantityByDecrease(self):
        self.room.quantityDecrease()

    def test_12VerifyMessageEnteringIrrelevantQuantity(self):
        self.room.enterIrrelevantDataInQuantity()

    def test_13VerifyProductDeleteButtonFunctionality(self):
        self.room.deleteRoomChangesApply()

    def test_14VerifyCancelButtonEditExistingTab(self):
        self.room.EditExistingCancelButton()
Ejemplo n.º 21
0
class GooglePage(SeleniumDriver):
    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators
    _search = "q"
    _search_btn = "btnK"
    _dummyclick = "lga"
    _lucky_btn2 = "gbqfbb"
    _results = "resultStats"
    _google = "//img[@title='30th Anniversary of the World Wide Web']"

    # ********************* Methods ************************************************************************************

    def clickSearch(self, search):
        self.waitForElement(locator=self._search,
                            locatorType="name",
                            timeout=15)
        self.sendKeys(search, locator=self._search, locatorType="name")

    def clickDummy(self):
        self.elementClick(locator=self._dummyclick, locatorType="id")

    def navigateToSearchBtn(self):
        self.elementClick(locator=self._search_btn, locatorType="name")

    # *************************** Implementation and Data **************************************************************

    def googleSearch(self, search):
        self.clickSearch(search)
        self.navigateToSearchBtn()
        time.sleep(2)

    # ************************* Assertions and Verifies ****************************************************************

    def verifySearch(self):
        self.waitForElement(locator=self._results,
                            locatorType="id",
                            timeout=10)
        result = self.isElementPresent(locator=self._results, locatorType="id")
        return result

    def startNew(self):
        self.elementClick(locator=self._google, locatorType="xpath")
        time.sleep(1)
class MeetingNotesTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.meeting = MeetingNotesPages(self.driver)

    def test_01VerifyMeetingNoteButton(self):
        self.log.info("*#" * 20)
        self.log.info(" test_01VerifyMeetingNoteButton ")
        self.log.info("*#" * 20)
        self.meeting.VerifyMeetingNoteButton()

    def test_02AddMeetingNotesBtoA(self):
        self.log.info("*#" * 20)
        self.log.info(" test_02AddMeetingNotesBtoA ")
        self.log.info("*#" * 20)
        self.meeting.AddMeetingNotes()

    def test_03VerifyAddedMeetingNotesOnNotesSection(self):
        self.log.info("*#" * 20)
        self.log.info(" test_03VerifyAddedMeetingNotesOnNotesSection ")
        self.log.info("*#" * 20)
        self.meeting.VerifyAddedMeetingNotesOnNotesSection()

    def test_04VerifyMeetingNotesButtonFromCtoB(self):
        self.log.info("*#" * 20)
        self.log.info(" test_04VerifyMeetingNotesButtonFromCtoB ")
        self.log.info("*#" * 20)
        self.meeting.VerifyMeetingNotesButtonFromCtoB()

    def test_05VerifyEnterValueInMeetingNotesModalBoxFromCToB(self):
        self.log.info("*#" * 20)
        self.log.info(" test_05VerifyEnterValueInMeetingNotesModalBoxFromCToB ")
        self.log.info("*#" * 20)
        self.meeting.EnterValueInMeetingNotesModalBoxFromCToB()

    def test_06VerifyVerifyAddedMeetingNotesOnNotesSectionFromCtoB(self):
        self.log.info("*#" * 20)
        self.log.info(" test_06VerifyVerifyAddedMeetingNotesOnNotesSectionFromCtoB ")
        self.log.info("*#" * 20)
        self.meeting.VerifyAddedMeetingNotesOnNotesSectionFromCtoB()

    def test_07VerifyPreviousMeetingNoteIsDisplayedAndEditableWhenReleaseIsCancelled(self):
        self.log.info("*#" * 20)
        self.log.info(" test_07VerifyPreviousMeetingNoteIsDisplayedAndEditableWhenReleaseIsCancelled ")
        self.log.info("*#" * 20)
        self.meeting.PreviousMeetingNoteIsDisplayedAndEditableWhenReleaseIsCancelled()
Ejemplo n.º 23
0
class RadioPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

#######################
#####  LOCATORS #######
#######################

    _male_radio1 = "//input[@value='Male' and @name ='optradio']"
    _female_radio1 = "//input[@value='Female' and @name ='optradio']"
    _check_value1 = "//button[@id='buttoncheck']"
    _male_radio1_confirm = "//p[contains(text(), \"Radio button 'Male' is checked\")]"
    _female_radio1_confirm = "//p[contains(text(), \"Radio button 'Female' is checked\")]"

    def clickMaleRadio1(self):
        self.elementClick(locator=self._male_radio1, locatorType="xpath")

    def clickFemaleRadio1(self):
        self.elementClick(locator=self._female_radio1, locatorType="xpath")

    def clickCheckValue1(self):
        self.elementClick(locator=self._check_value1, locatorType="xpath")

    def verifyTitle(self):
        self.nav.navigateToRadioPage()
        return self.verifyPageTitle(
            "Selenium Easy Demo - Radio buttons demo for Automation")

    def verifyRadioMale(self):
        self.clickMaleRadio1()
        self.clickCheckValue1()
        result = self.isElementPresent(locator=self._male_radio1_confirm,
                                       locatorType="xpath")

        return result

    def verifyRadioFemale(self):
        self.clickFemaleRadio1()
        self.clickCheckValue1()
        result = self.isElementPresent(locator=self._female_radio1_confirm,
                                       locatorType="xpath")

        return result
Ejemplo n.º 24
0
class LoginPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators
    _login_link = "a[href='/login']"
    _email_field = "input[placeholder='Email Address']"
    _password_field = "password"
    _login_button = "//input[@value='Login']"

    def clickLoginLink(self):
        self.elementClick(self._login_link, locatorType="css")

    def enterEmail(self, email):
        self.sendKeys(email, self._email_field, locatorType="css")

    def enterPassword(self, password):
        self.sendKeys(password, self._password_field)

    def clickLoginButton(self):
        self.elementClick(self._login_button, locatorType="xpath")

    def login(self, email="", password=""):
        try:
            self.clickLoginLink()
            self.enterEmail(email)
            self.enterPassword(password)
            self.clickLoginButton()
        except:
            print("Some Eception Occured")

    def verifyLoginSuccessful(self):
        result = self.isElementPresent("//button[@id='dropdownMenu1']/img",
                                       locatorType="xpath")
        return result

    def verifyLoginFailed(self):
        result = self.isElementPresent(
            "//div[@class='form-group has-error']//span[contains(text(), 'username or password is invalid')]",
            locatorType="xpath")
        return result

    def verifyLoginTitle(self):
        return self.verifyPageTitle("All Courses")
Ejemplo n.º 25
0
class RegisterCoursesPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    # Locators
    _search_box = "search-courses"
    _search_icon = "search-course-button"
    _course = "//div[contains(@class,'course-listing-title') and contains(text(),'{0}')]"
    _all_courses = "//div[@class='course-listing-title']"
    _enroll_button = "enroll-button-top"
    _postal_code_field = "billingPostalCode"
    _buy_now_button = "//div[@id='react-checkout']//div[@class='m-b-4-xs _3pM7B']//span[1]"
    _error_message = "//li[contains(text(),'Sorry, there was an error completing your purchase -- please try again.')]"


    # Element interactions
    def enterCourseName(self, name):
        self.sendKeys(name, locator=self._search_box)
        self.clickElement(locator=self._search_icon)

    def selectCourseToEnroll(self, fullCourseName):
        self.clickElement(locator=self._course.format(fullCourseName), locatorType="xpath")

    def clickOnEnrollButton(self):
        self.clickElement(locator=self._enroll_button)

    def enterPostalCode(self, code):
        self.sendKeys(code, locator=self._postal_code_field)

    def clickBuyNowButton(self):
        self.clickElement(locator=self._buy_now_button, locatorType="xpath")

    def enrollCourse(self, code=""):
        self.clickOnEnrollButton()
        self.webScroll(direction="down")
        self.enterPostalCode(code)
        self.clickBuyNowButton()
        time.sleep(5)
        self.webScroll(direction="up")

    def verifyEnrollFailed(self):
        messageElement = self.waitForElement(self._error_message, locatorType="xpath")
        result = self.isElementDisplayed(element=messageElement)
        return result
Ejemplo n.º 26
0
class AddressPage(BasePage):
    log = cl.customLogger(logging.DEBUG)

    # Constructor will accept driver
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver

    #     Locators

    _accounts_xpath = "//*[@id='nav-link-accountList']/span[2]"
    _yourAccount_link = "Your Account"
    _yourAddress_xpath = "//h2[contains(text(),'Your Addresses')]"
    _addAddress_xpath = "//h2[contains(text(),'Add address')]"
    _fullname_id = "address-ui-widgets-enterAddressFullName"
    _mobile_number_id = "address-ui-widgets-enterAddressPhoneNumber"

    #Actions

    def mouseHoverOnAccout(self):
        self.mouseHover(self._accounts_xpath, locatorType="xpath")

    def clickOnYourAccount(self):
        self.elementClick(self._yourAccount_link, locatorType="link")

    def clickOnAddressTab(self):
        self.elementClick(self._yourAddress_xpath, locatorType="xpath")

    def clickOnAddAddress(self):
        self.elementClick(self._addAddress_xpath, locatorType="xpath")

    def sendFullName(self, data):
        self.sendKeys(data, self._fullname_id, locatorType="id")

    def mobileNum(self, data):
        self.sendKeys(data, self._mobile_number_id, locatorType="id")

    # Logic

    def addNewAddress(self, fullname=""):
        self.mouseHoverOnAccout()
        self.clickOnYourAccount()
        time.sleep(2)
        self.clickOnAddressTab()
        self.clickOnAddAddress()
        self.sendFullName(fullname)
        mobile = Util.getUniqueMobileNo()
        self.mobileNum(mobile)
Ejemplo n.º 27
0
class TestStatus(SeleniumDriver):
    log = cl.customLogger(logging.INFO)

    def __init__(self, driver):
        """
        Inits CheckPoint class
        """
        super(TestStatus, self).__init__(driver)
        self.resultList = []

    def setResult(self, result, resultMessage):
        try:
            if result is not None:
                if result:
                    self.resultList.append("PASS")
                    print("### VERIFICATION SUCCESSFUL :: + " + resultMessage)
                else:
                    self.resultList.append("FAIL")
                    print("### VERIFICATION FAILED :: + " + resultMessage)
            else:
                self.resultList.append("FAIL")
                print("### VERIFICATION FAILED :: + " + resultMessage)
        except:
            self.resultList.append("FAIL")
            print("### Exception Occurred !!!")

    def mark(self, result, resultMessage):
        """
        Mark the result of the verification point in a test case
        """
        self.setResult(result, resultMessage)

    def markFinal(self, testName, result, resultMessage):
        """
        Mark the final result of the verification point in a test case
        This needs to be called at least once in a test case
        This should be final test status of the test case
        """
        self.setResult(result, resultMessage)

        if "FAIL" in self.resultList:
            print(testName + " ### TEST FAILED")
            self.resultList.clear()
            assert True == False
        else:
            print(testName + " ### TEST SUCCESSFUL")
            self.resultList.clear()
            assert True == True
class LoginPage(BasePage):

    log = cl.customLogger(logging.DEBUG)

    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.nav = NavigationPage(driver)

    # locators
    _login_link = "//a[@href='/login']"
    _email_field = "email"
    _password_field = "password"
    _login_button = "//input[@value='Login']"

    def clickLoginLink(self):
        self.elementCLick(self._login_link, locatorType="xpath")

    def enterEmail(self, email):
        self.sendKeys(email, self._email_field)

    def enterPassword(self, password):
        self.sendKeys(password, self._password_field)

    def clickLoginButton(self):
        self.elementCLick(self._login_button, locatorType="xpath")

    def login(self, email="", password=""):
        self.clickLoginLink()
        self.enterEmail(email)
        self.enterPassword(password)
        self.clickLoginButton()

    def verifyLoginSuccessful(self):
        result = self.isElementPresent("//button[@id='dropdownMenu1']/img", locatorType="xpath")
        return result

    def verifyLoginFailed(self):
        result = self.isElementPresent(locator="//span[contains(text(), 'Your username or password is invalid.')]",
                                       locatorType="xpath")
        return result

    def verifyTitle(self):
        return self.verifyPageTitle("All Courses")

    def logout(self):
        self.nav.navigateToUserIcon()
        self.elementCLick("Logout", locatorType="link")
Ejemplo n.º 29
0
class GitPageTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, oneTimeSetUp):
        self.login = LoginPage(self.driver)
        self.nr = ClickNewRepo(self.driver)
        self.cr = CreateNewRepo(self.driver)
        self.cn = CreateNewIssue(self.driver)
        self.tn = ToolbarNav(self.driver)

    @pytest.mark.run(order=1)
    @data(*getCSVData("testdata.csv"))
    @unpack
    def test_challange1(self, user_id, password):
        self.login.logins(userid=user_id, password=password)
        self.nr.clickNew()
        self.cr.createRepo()

    @pytest.mark.run(order=2)
    def test_challenge2(self):
        global TEXT
        self.tn.clickIssue()
        self.tn.clickIssueButton()
        self.cn.crtIssue(title="git_title" + str(random.randrange(1, 999878)),
                         desc="git_desc" + str(random.randrange(1, 987899)))
        TEXT = self.cn.getPreIssue()
        self.cn.clkIssue()
        self.cn.crtIssue(title=TEXT[:-3], desc=TEXT[:-3])

    @pytest.mark.run(order=3)
    def test_challenge3(self):
        self.cn.comment(data="Entering Comments")
        self.cn.sendEmoji()

    @pytest.mark.run(order=4)
    def test_challenge4(self):
        time.sleep(2)
        self.tn.clickIssue()
        self.cn.issueListclk()
        self.cn.comment(data=TEXT)
        self.cn.cmntListclk()

    @pytest.mark.run(order=5)
    @data(*getCSVData("testdata.csv"))
    @unpack
    def test_challenge5(self, user_id, password):
        self.cr.deleteRepo(password=password)
class Test_ControllerTests(unittest.TestCase):
    log = cl.customLogger(logging.DEBUG)

    @pytest.fixture(autouse=True)
    def objectSetup(self, universalSetUp):
        self.cp = ControllerPages(universalSetUp)

    #    self.cp = ControllerPages(self.driver)
    #    self.ts = Status(self.driver)

    #to handle whatfix #
    """    
    @pytest.mark.run(order = 0)
    def test_close_whatfix_window(self): 
        self.log.info("try to close whatfix_window")
        self.cp.close_Whatfix_Windows()
        self.log.info("close_whatfix_window") 
       """
    # @pytest.mark.run(after = "test_close_whatfix_window")
    # def test_open_add_window(self):
    # self.log.info("test_open_add_window")
    # self.cp.navigate_to_Controller_Add_window()

    @pytest.mark.run(order=0)
    def test_t1AddController(self):
        self.log.info("*#" * 20)
        self.log.info("test_t1Addcontroller start")
        self.log.info("*#" * 20)
        self.log.info("navigate to controller page")
        self.cp.navigate_to_Controller_Add_window()
        self.log.info("navigate to controller Add page")
        self.cp.add_Single_Controller("isademo", "test", "TCP", "1470",
                                      "10.14.70.0", "27")
        self.log.info(
            "controller add process complete now verify newly added controller"
        )
        result = self.cp.verify_Controller_entry("test")
        assert result == True

    @pytest.mark.run(after="test_t1AddController")
    def test_delete_controller(self):
        self.log.info("*#" * 20)
        self.log.info("test_delete_controller")
        self.log.info("*#" * 20)
        self.log.info("navigate to controller page")
        self.cp.navigateControllerPage()
        result = self.cp.delete_Sigle_Controller("test")
        assert result == True