class UserPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def admin_tab(self):
        self.admin = self.driver.find_element(By.XPATH, '//*[@id="menu_admin_viewAdminModule"]').click()
        time.sleep(3)
        return self

    def add_btn(self):
        self.add = Button(By.ID, 'btnAdd').click()
        time.sleep(3)

    def add_user(self):
        self.user_role = self.driver.find_element(By.XPATH, '//*[@id="systemUser_userType"]/option[@value=2]').click()
        time.sleep(2)
        self.employee_name = self.driver.find_element(By.XPATH, '//*[@id="systemUser_employeeName_empName"]').send_keys('Robert Craig')
        time.sleep(2)
        self.username = self.driver.find_element(By.XPATH, '//*[@id="systemUser_userName"]').send_keys('robert.craig')
        time.sleep(2)
        self.status = self.driver.find_element(By.XPATH, '//*[@id="systemUser_status"]/option[@value=1]').click()
        time.sleep(2)
        self.password = self.driver.find_element(By.XPATH, '//*[@id="systemUser_password"]').send_keys('Passw0rd123')
        time.sleep(2)
        self.confirm_pass = self.driver.find_element(By.XPATH, '//*[@id="systemUser_confirmPassword"]').send_keys('Passw0rd123')
        time.sleep(2)
        self.save_button = Button(By.XPATH, '//*[@id="btnSave"]').click()
        time.sleep(5)
示例#2
0
class AddEmployeePageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def pim_tab(self):
        self.pim_click = self.driver.find_element(
            By.XPATH, '//*[@id="menu_pim_viewPimModule"]').click()
        time.sleep(3)
        return self

    def add_employee(self):
        self.employee = self.driver.find_element(
            By.XPATH, '//*[@id="menu_pim_addEmployee"]').click()
        time.sleep(3)
        return self

    def empl_details(self):
        self.first_name = self.driver.find_element(
            By.XPATH, '//*[@id="firstName"]').send_keys('Steve')
        self.last_name = self.driver.find_element(
            By.XPATH, '//*[@id="lastName"]').send_keys('Smith')
        self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()
        time.sleep(3)
        return self
示例#3
0
文件: login.py 项目: bongadub/Bonga
class LoginPage(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()
        


    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)
示例#4
0
class LoginPage(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        time.sleep(5)
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)
class CandidatesPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'txtUsername')
        self.password = InputText(By.NAME, 'txtPassword')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/submit'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)

        return self

    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewRecruitmentModule"]/b')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(3)

        return self

    def click_candidates(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewCandidates"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def click_add(self):
        self.click_element = self.driver.find_element(By.XPATH,
                                                      '//*[@id="btnAdd"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def fill_form(self):
        self.fname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_firstName"]').send_keys("Samkelo")
        self.mname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_middleName"]').send_keys("Sam")
        self.lname = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_lastName"]').send_keys("Samkelo")
        self.email = self.driver.find_element(
            By.XPATH, '//*[@id="addCandidate_email"]').send_keys(
                "*****@*****.**")
        self.cnumber = self.driver.find_element(
            By.XPATH,
            '//*[@id="addCandidate_contactNo"]').send_keys("780479246")

        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.save_btn = Button(By.XPATH, '//*[@id="btnSave"]').click()

        time.sleep(3)

        return self

    def back_btn(self):
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.back_btn = Button(By.XPATH, '//*[@id="btnBack"]').click()

        time.sleep(3)

        return self

    def dlt_record(self):
        self.driver.execute_script(
            "window.scrollTo(0, document.body.scrollHeight);")
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="ohrmList_chkSelectAll"]')

        self.driver.implicitly_wait(15)
        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        self.driver.find_element(By.XPATH, '//*[@id="btnDelete"]').click()
        self.driver.implicitly_wait(10)
        #self.driver.find_element(By.XPATH, '//*[@id="dialogDeleteBtn"]').click()

        time.sleep(5)

        return self
示例#6
0
class Buying_ItemPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'email')
        self.password = InputText(By.NAME, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(3)
        self.login_button.click()
        time.sleep(3)

    # return SecureAreaPageObject(self.driver_wrapper)

    #hover over the women tab
    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="block_top_menu"]/ul/li[1]/a')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(3)

        return self

        #hover over women tab and move cursor to blouses and click
    def click_tops(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="block_top_menu"]/ul/li[1]/ul/li[1]/ul/li[2]/a')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(3)

        return self

    def addItem(self):
        #scroll to bottom
        self.driver.execute_script(
            "window.scrollTo(0, -170, document.body.scrollHeight);")

        #Hover to blouse and click add to cart button
        self.item = self.driver.find_element(
            By.XPATH, '//*[@id="center_column"]/ul/li/div/div[2]/h5/a')

        self.button = ActionChains(self.driver).move_to_element(
            self.item).perform()

        self.add_to_cart = self.driver.find_element(
            By.XPATH,
            '//*[@id="center_column"]/ul/li/div/div[2]/div[2]/a[1]').click()
        time.sleep(3)

        return self

        #click Proceed to checkout button to shopping-cart summary page
    def go_to_checkout(self):
        self.checkout = self.driver.find_element(
            By.XPATH, '//*[@id="layer_cart"]/div[1]/div[2]/div[4]/a').click()
        time.sleep(3)

        return self

        #click proceed button to addresses page
    def shopping_summary(self):
        self.summary = self.driver.find_element(
            By.XPATH, '//*[@id="center_column"]/p[2]/a[1]').click()
        time.sleep(3)

        return self

        #click proceed button to shipping page
    def address_verification(self):
        self.address = Button(By.NAME, 'processAddress').click()
        time.sleep(3)

        return self

        #click the agree on terms checkbox buttton
    def agree_on_terms(self):
        self.agree_terms = self.driver.find_element(By.XPATH,
                                                    '//*[@id="cgv"]').click()
        time.sleep(3)

        return self

        #click Proceed to checkout button to payment method page
    def shipping_page(self):
        self.shipping = Button(By.NAME, 'processCarrier').click()
        time.sleep(3)

        return self

        #Click payment method button
    def payment_method(self):
        self.payment_type = self.driver.find_element(
            By.XPATH, '//*[@id="HOOK_PAYMENT"]/div[2]/div/p/a').click()
        time.sleep(3)

        return self

        #Click confirm order button
    def confirm_order(self):
        self.confirm_order = self.driver.find_element(
            By.XPATH, '//*[@id="cart_navigation"]/button').click()
        time.sleep(10)

        self.confirm_order = self.driver.find_element(
            By.XPATH, '//*[@id="header"]/div[2]/div/div/nav/div[2]/a').click()
        time.sleep(5)

        return self
示例#7
0
class AssignLeavePageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.XPATH, '//*[@id="txtUsername"]')
        self.password = InputText(By.XPATH, '//*[@id="txtPassword"]')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        self.logger.debug("Login with user '%s'", user['username'])
        time.sleep(5)
        self.username.text = user['username']
        self.password.text = user['password']
        self.login_button.click()
        time.sleep(5)

    def assign_leave(self):
        self.assign_leave_btn = self.driver.find_element(
            By.XPATH,
            '//*[@id="dashboard-quick-launch-panel-menu_holder"]/table/tbody/tr/td[1]/div/a'
        ).click()
        time.sleep(3)
        return self

    def leave_details(self):
        self.empl_name = self.driver.find_element(
            By.XPATH,
            '//*[@id="assignleave_txtEmployee_empName"]').send_keys('J')
        time.sleep(2)
        self.list = self.driver.find_element(
            By.XPATH, '/html/body/div[6]/ul/li[1]').click()
        time.sleep(2)
        self.leave_type = self.driver.find_element(
            By.XPATH,
            '//*[@id="assignleave_txtLeaveType"]/option[@value=1]').click()
        time.sleep(2)
        self.from_date = self.driver.find_element(
            By.XPATH, '//*[@id="assignleave_txtFromDate"]').click()
        time.sleep(2)
        self.start_date = self.driver.find_element(
            By.XPATH,
            '//*[@id="ui-datepicker-div"]/table/tbody/tr[4]/td[4]/a').click()
        time.sleep(2)
        self.to_date = self.driver.find_element(
            By.XPATH, '//*[@id="assignleave_txtToDate"]').click()
        time.sleep(5)
        self.end_date = self.driver.find_element(
            By.XPATH,
            '//*[@id="ui-datepicker-div"]/table/tbody/tr[5]/td[5]/a').click()
        time.sleep(5)
        self.button = Button(By.XPATH, '//*[@id="assignBtn"]').click()
        time.sleep(5)

    def ok_btn(self):
        self.OK_button = Button(By.XPATH, '//*[@id="confirmOkButton"]').click()
        time.sleep(5)
        return self
示例#8
0
class SearchPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.ID, 'email')
        self.password = InputText(By.ID, 'passwd')
        self.login_button = Button(By.ID, 'SubmitLogin')

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.logger.debug("\nAtempting to open the page")
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))

        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        try:
            self.logger.debug("Login with user '%s'", user['username'])
            self.username.text = user['username']
            self.password.text = user['password']
            self.logger.debug("\nAtempting to click login button")
            self.login_button.click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
            return None

    def search(self):
        try:
            self.search_item = self.driver.find_element(
                By.XPATH, '//*[@id="search_query_top"]').send_keys('t-shirt')
            self.search_btn = self.driver.find_element(
                By.XPATH, '//*[@id="searchbox"]/button').click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
            return None

    def add_item(self):
        try:
            self.driver.execute_script(
                "window.scrollTo(0, 200, document.body.scrollHeight)")
            self.item = self.driver.find_element(
                By.XPATH, '//*[@id="center_column"]/ul/li/div/div[2]/h5/a')
            self.hover = ActionChains(self.driver).move_to_element(
                self.item).perform()
            self.add_btn = self.driver.find_element(
                By.XPATH,
                '//*[@id="center_column"]/ul/li/div/div[2]/div[2]/a[2]').click(
                )
            self.add_to_cart = self.driver.find_element(
                By.XPATH, '//*[@id="add_to_cart"]/button').click()
            time.sleep(3)

            return True
        except NoSuchElementException:
            self.auto_log("error", "Element {} does not exist".format(element))
class VacanciesPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.NAME, 'txtUsername')
        self.password = InputText(By.NAME, 'txtPassword')
        self.login_button = Button(By.XPATH, '//*[@id="btnLogin"]')

        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/submit'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded

        :returns: this page object instance
        """
        self.username.wait_until_visible()
        return self

    def login(self, user):
        """ Fill login form and submit it

        :param user: dict with username and password values
        :returns: secure area page object instance
        """
        #self.logger.debug("Login with user '%s'", user['username'])
        self.username.text = user['username']
        self.password.text = user['password']
        time.sleep(5)
        self.login_button.click()
        time.sleep(10)

        return self
        #hover abover recruitment tab and make a cursor move to the vacancies tab
    def hover(self):
        self.element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewRecruitmentModule"]/b')

        self.hover = ActionChains(self.driver).move_to_element(
            self.element).perform()
        time.sleep(5)

        return self
        #clicks on vacancies
    def click_vacancies(self):
        self.click_element = self.driver.find_element(
            By.XPATH, '//*[@id="menu_recruitment_viewJobVacancy"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(5)

        return self

    def click_add(self):
        self.click_element = self.driver.find_element(By.XPATH,
                                                      '//*[@id="btnAdd"]')

        self.hover = ActionChains(self.driver).move_to_element(
            self.click_element).click(self.click_element).perform()

        time.sleep(5)

        return self