예제 #1
0
 def create_employee(self, first_name, last_name):
     """
     Go to PIM, check employee and create a new employee
     """
     self.pim = AddEmployee(self.driver)
     self.pim.delete_employee(last_name)
     self.pim.add_user_employee(first_name, last_name)
예제 #2
0
 def create_employee(self, first_name, last_name):
     """
     Go to PIM, check employee and create a new employee
     """
     self.pim = AddEmployee(self.driver)
     self.sleep(3)
     self.pim.add_user_employee(first_name, last_name)
     Log.info("Arrive Add Employee page")
예제 #3
0
 def add_employee(self, first_name, last_name):
     """
     Go to PIM page to add an employee with first and lats name
     """
     self.switch_main_menu("PIM")
     self.click_menu("Add Employee")
     self.pim = AddEmployee(self.driver)
     self.pim.add_user_employee(first_name, last_name)
예제 #4
0
 def test_search_and_update(self):
     self.user.create_employee(self.employee_first_name,
                               self.employee_last_name)
     self.user.switch_main_menu("admin")
     self.user.add_user(self.user_role_value, self.employee_name,
                        self.user_name_value, self.user_status_value,
                        self.user_pwd_value)
     self.user.search(self.user_name_value)
     self.user.update_user(self.user_name_value, self.updated_user_name)
     self.user.search(self.updated_user_name)
     self.user.delete(self.updated_user_name)
     self.pim = AddEmployee(self.driver)
     self.pim.delete_employee(self.employee_last_name)
예제 #5
0
class TestLeaveList(unittest.TestCase):
    """
    Test leave list page functions
    """
    f_name = ''.join(random.sample(string.ascii_letters + string.digits, 8))
    l_name = ''.join(random.sample(string.ascii_letters + string.digits, 2))

    emp_name = f_name + " " + l_name
    leave_type = "FMLA US"
    from_date = "2018-06-12"
    to_date = "2018-06-17"

    date_from = "2018-01-01"
    date_to = "2019-12-31"
    cancel = "Cancel"
    # message = ('XPATH', "//*[@class='message success fadable']")
    status = "Cancelled"

    @classmethod
    def setUpClass(cls):
        cls.driver = utils.get_browser_driver(config.BROWSER)
        cls.login = Login(cls.driver)
        cls.login.open_browser(config.LOGIN_URL)
        cls.login.login(config.USER_NAME, config.PASSWORD)

    def test_add_employee(self):
        self.addemployee = AddEmployee(self.driver)
        self.addemployee.add_user_employee(self.f_name, self.l_name)

    def test_assign_leave(self):
        self.assignleave = AssignLeave(self.driver)
        self.assignleave.select_menu()
        self.assignleave.select_name_and_type(self.leave_type, self.emp_name)
        self.assignleave.input_date(self.from_date, self.to_date)
        time.sleep(3)
        self.assignleave.assign()

    def test_cancel_leave_list(self):
        self.leavelist = LeaveList(self.driver)
        self.leavelist.search_leave_list(self.date_from, self.date_to)
        self.leavelist.verify_employee_name(self.emp_name)
        # self.leavelist.leave_list_action(self.cancel)
        self.leavelist.leave_list_action_via_empname(self.emp_name,
                                                     self.cancel)
        self.leavelist.verify_leave_list_status(self.status)

    @classmethod
    def tearDownClass(cls):
        cls.login.quit_browser()
예제 #6
0
 def setUpClass(cls):
     cls.driver = utils.get_browser_driver(cls.browser)
     cls.login = Login(cls.driver)
     cls.login.open_browser(config.LOGIN_URL)
     cls.login.login(config.USER_NAME, config.PASSWORD)
     cls.addemployee = AddEmployee(cls.driver)
     cls.addemployee.add_user_employee(cls.first_name, cls.last_name)
예제 #7
0
 def cancel_del_employee(self, employee):
     """
     Cancel delete employee function
     """
     # Check if the employee exist
     check_flag = self.query_employee_by_name(employee)
     if check_flag is False:
         firstname = employee.split()[0]
         lastname = employee.split()[1]
         addemployee = AddEmployee(self.driver)
         addemployee.add_user_employee(firstname, lastname)
         self.click_menu("Employee List")
         Log.info("Back to Employee list page after create new employee")
         self.query_employee_by_name(employee)
     # Delete the employee
     self.click(self.select_row)
     self.click(self.delete_btn)
     assert 'Delete records?' == self.get_element_text(self.delete_box)
     self.click(self.cancel_btn)
     Log.info("Cancel of employee deletion succeed")
예제 #8
0
class SearchAndUpdateUser(unittest.TestCase):
    """
    Test search user functions
    """

    browser = config.BROWSER
    employee_first_name = "epm"
    employee_last_name = "suzhou"
    employee_name = "epm suzhou"
    user_role_value = "ESS"
    user_name_value = "sandy"
    user_status_value = "Enabled"
    user_pwd_value = "123456"
    updated_user_name = "test0"

    @classmethod
    def setUpClass(cls):
        cls.driver = utils.get_browser_driver(cls.browser)
        cls.login = Login(cls.driver)
        cls.login.open_browser(config.LOGIN_URL)
        cls.login.login(config.USER_NAME, config.PASSWORD)
        cls.user = Users(cls.driver)

    def test_search_and_update(self):
        self.user.create_employee(self.employee_first_name,
                                  self.employee_last_name)
        self.user.switch_main_menu("admin")
        self.user.add_user(self.user_role_value, self.employee_name,
                           self.user_name_value, self.user_status_value,
                           self.user_pwd_value)
        self.user.search(self.user_name_value)
        self.user.update_user(self.user_name_value, self.updated_user_name)
        self.user.search(self.updated_user_name)
        self.user.delete(self.updated_user_name)
        self.pim = AddEmployee(self.driver)
        self.pim.delete_employee(self.employee_last_name)

    @classmethod
    def tearDownClass(cls):
        cls.login.quit_browser()
예제 #9
0
 def delete_employee(self, employee):
     """
     Delete employee:
     1. Search for employee
     2. choose the employee and click the delete option(cancel/ok)
     """
     # Check if the employee exist
     check_flag = self.query_employee_by_name(employee)
     if check_flag is False:
         firstname = employee.split()[0]
         lastname = employee.split()[1]
         addemployee = AddEmployee(self.driver)
         addemployee.add_user_employee(firstname, lastname)
         self.click_menu("Employee List")
         Log.info("Back to Employee list page after create new employee")
         self.query_employee_by_name(employee)
     # Delete the employee
     self.click(self.select_row)
     self.click(self.delete_btn)
     assert 'Delete records?' == self.get_element_text(self.delete_box)
     self.click(self.ok_btn)
     assert 'No Records Found' == self.get_element_text(self.delete_result)
     Log.info('Employee deleted successfully')
예제 #10
0
class Users(Admin):
    user_management_menu = ("id", "menu_admin_UserManagement")

    # Define element keys on User page: Search panel
    search_username = ("id", "searchSystemUser_userName")
    search_role = ("id", "searchSystemUser_userType")
    search_employee = ("id", "searchSystemUser_employeeName_empName")
    search_status = ("id", "searchSystemUser_status")
    search_btn = ("id", "searchBtn")
    reset_btn = ("id", "resetBtn")

    # Define element keys on User page: elements on user table panel
    user_add_btn = ("id", "btnAdd")
    user_del_btn = ("id", "btnDelete")
    username_list = ("xpath", "//table[@id='resultTable']/tbody/tr/td[2]/a")
    user_role_list = ("xpath", "//table[@id='resultTable']/tbody/tr/td[3]")
    employee_name_list = ("xpath", "//table[@id='resultTable']/tbody/tr/td[4]")
    user_status_list = ("xpath", "//table[@id='resultTable']/tbody/tr/td[5]")
    user_checkbox_xpath = "//a[contains(text(), '{}')]/../../td[1]"
    username_link_xpath = "//a[contains(text(), '{}')]/../../td[2]/a"
    no_record_element = ("xpath", "//table[@id='resultTable']/tbody/tr/td")
    user_table = ("id", "resultTable")

    # Define element keys on Add User panel
    emp_name_input = ("id", "systemUser_employeeName_empName")
    user_name_input = ("id", "systemUser_userName")
    user_role_select = ("id", "systemUser_userType")
    user_status_select = ("id", "systemUser_status")
    user_password_input = ("id", "systemUser_password")
    user_confirm_password = ("id", "systemUser_confirmPassword")
    user_save_btn = ("id", "btnSave")
    user_cancel_btn = ("id", "btnCancel")
    add_user_form = ("id", "frmSystemUser")

    # Define elements on User Delete dialog
    dialog_del_btn = ("id", "dialogDeleteBtn")

    # Define elements on Edit User panel
    user_edit_save_btn = ("id", "btnSave")
    change_password = ("id", "systemUser_chkChangePassword")

    def __init__(self, browser):
        super(Users, self).__init__(browser)

    def add_employee(self, first_name, last_name):
        """
        Go to PIM page to add an employee with first and lats name
        """
        self.switch_main_menu("PIM")
        self.click_menu("Add Employee")
        self.pim = AddEmployee(self.driver)
        self.pim.add_user_employee(first_name, last_name)

    def open_user_page(self):
        """
        Open Admin->User Management->Users page
        """
        self.switch_main_menu("Admin")
        self.wait_unit_el_present(self.user_management_menu)
        self.click_menu("User Management")
        self.click_menu("Users")

    def get_all_users(self):
        """
        :return a dictionary which include the username, employee name, role, status details
        Note: dictionary is not ordered in python.
        """
        all_user_info = dict()
        all_user_info["UserName"] = self.get_elements_texts(self.username_list)
        all_user_info["EmployeeName"] = self.get_elements_texts(
            self.employee_name_list)
        all_user_info["UserRole"] = self.get_elements_texts(
            self.user_role_list)
        all_user_info["UserStatus"] = self.get_elements_texts(
            self.user_status_list)
        return all_user_info

    def check_if_user_exists(self, username):
        """
        check if the username listed in the user table, if existing then return True else return False
        """
        if username in self.get_elements_texts(self.username_list):
            return True
        else:
            return False

    def add_user(self, role, emp_name, username, status, password):
        """
        On Users page, by Add button, add a new user with role, employee name, user name, status and password
        """
        Log.info("Start to add user.")
        self.click(self.user_add_btn)
        self.wait_unit_el_present(self.add_user_form)
        self.set_combox_value(role, self.user_role_select)
        self.input_text(emp_name, self.emp_name_input)
        self.input_text(username, self.user_name_input)
        self.set_combox_value(status, self.user_status_select)
        self.input_text(password, self.user_password_input)
        self.input_text(password, self.user_confirm_password)
        self.click(self.user_save_btn)
        self.wait_unit_el_present(self.user_table)
        Log.info("New user is added.")

    def delete_user(self, username):
        """
        On Users page, by delete button, delete the selected user (this is only for single user)
        """
        Log.info("Start to delete user.")
        if self.check_if_user_exists(username):
            self.click(("xpath", self.user_checkbox_xpath.format(username)))
            self.click(self.user_del_btn)
            self.click(self.dialog_del_btn)
            self.wait_unit_el_present(self.user_table)
            Log.info("Use is deleted.")
        else:
            Log.info("User " + username +
                     " is not in the user list, not delete.")

    def open_user(self, username):
        """
        On Users page, click username to open a user (to go to Edit User page)
        """
        if self.check_if_user_exists(username):
            self.click(("xpath", self.username_link_xpath.format(username)))
            self.wait_unit_el_present(self.user_edit_save_btn)
        else:
            Log.info("User " + username + " is not in the user list.")

    def get_user_info(self):
        """
        On Edit User page, get the username, employee name, role and status
        """
        name = self.get_element_attribute(self.user_name_input, "value")
        role = self.get_first_select(self.user_role_select)
        employee = self.get_element_attribute(self.emp_name_input, "value")
        status = self.get_first_select(self.user_status_select)
        info = [name, employee, role, status]
        return info

    def edit_user(self,
                  username,
                  employee,
                  role,
                  status,
                  change_pwd=False,
                  *password):
        """
        On Edit Users page, edit an user
        """
        self.click(self.user_edit_save_btn)
        self.set_combox_value(role, self.user_role_select)
        self.input_text(employee, self.emp_name_input)
        self.input_text(username, self.user_name_input)
        self.set_combox_value(status, self.user_status_select)
        if change_pwd:
            self.click(self.change_password)
            self.input_text(password, self.user_password_input)
            self.input_text(password, self.user_confirm_password)
        self.click(self.user_edit_save_btn)
        self.wait_unit_el_present(self.user_table)
        Log.info("User is edited and saved.")

    def click_search(self):
        self.click(self.search_btn)

    def click_reset(self):
        self.click(self.reset_btn)

    def search_system_user(self,
                           username="",
                           employee="",
                           role="All",
                           status="All"):
        """
        On Users page, input keywords for username, employee name, role, status, then click search button to search

        """
        self.clear_text(self.search_username)
        self.input_text(username, self.search_username)
        self.clear_text(self.search_employee)
        self.input_text(employee, self.search_employee)
        self.set_combox_value(role, self.search_role)
        self.set_combox_value(status, self.search_status)
        self.click_search()
        self.wait(1)
        Log.info("Search user is done.")

    def get_search_info(self):
        """
        On User page, get the text of search input controls: username, employee name, role and status
        """
        name = self.get_element_attribute(self.search_username, "value")
        employee = self.get_element_attribute(self.search_employee, "value")
        role = self.get_first_select(self.search_role)
        status = self.get_first_select(self.search_status)
        info = [name, employee, role, status]
        return info
예제 #11
0
class Directory(MainPage):
    """
    Directory page main components
    """
    name = ('id', 'searchDirectory_emp_name_empName')
    jobtitle = ('id', 'searchDirectory_job_title')
    location = ('id', 'searchDirectory_location')
    searchbutton = ('id', 'searchBtn')
    resetbutton = ('id', 'resetBtn')
    resulttable = ('id', 'resultBox')
    No_records_Found = ('XPATH', ".//*[@id='content']/div[2]/div[2]")

    def __init__(self, browser):
        """
        Arrive Directory page-Search Directory
        """
        super(Directory, self).__init__(browser)
        self.switch_main_menu("Directory")
        Log.info("Arrive Directory page")

    def create_employee(self, first_name, last_name):
        """
        Go to PIM, check employee and create a new employee
        """
        self.pim = AddEmployee(self.driver)
        self.pim.delete_employee(last_name)
        self.pim.add_user_employee(first_name, last_name)

    def delete_employee(self, last_name):
        """
        Go to PIM, delete an employee
        """
        self.pim = AddEmployee(self.driver)
        self.pim.delete_employee(last_name)

    def resetDirectory(self, Name, JobTitle, Location):
        """
        Test reset name, job title and location on Search Directory
        """
        #Reset name, job title and location at one time
        self.clear_text(self.name)
        self.input_text(value=Name, keys=self.name)
        self.press_enter_key(self.name)
        self.sleep(2)
        self.set_combox_value(value=JobTitle, keys=self.jobtitle)
        self.sleep(2)
        self.set_combox_value(value=Location, keys=self.location)
        self.sleep(2)
        self.click(self.resetbutton)
        self.sleep(2)
        assert self.get_element_text(self.name) == ""
        DefaultOptionValue_jobtitle = self.get_element_attribute(
            self.jobtitle, "value")
        assert DefaultOptionValue_jobtitle == "0"
        DefaultOptionValue_location = self.get_element_attribute(
            self.location, "value")
        assert DefaultOptionValue_location == "-1"
        Log.info(
            "Directory Page, reset name, job title and location for search directory - all passed"
        )

    def searchDirectory_One(self, Name, JobTitle, Location):
        """
        Test search name, job title and location on Search Directory
        """
        #Search name only
        self.input_text(value=Name, keys=self.name)
        self.press_enter_key(self.name)
        self.click(self.searchbutton)
        enter_name = self.get_element_attribute(self.name, "Value")
        queryout_name = self.get_element_text(self.resulttable)
        assert enter_name in queryout_name
        Log.info("Directory Page, search name for search directory - passed")

        #Search job title only
        self.click(self.resetbutton)
        self.set_combox_value(value=JobTitle, keys=self.jobtitle)
        self.click(self.searchbutton)
        queryout_jobtitle = self.get_element_text(self.resulttable)
        assert JobTitle in queryout_jobtitle
        Log.info(
            "Directory Page, search job title for search directory - passed")

        # Search location only
        self.click(self.resetbutton)
        self.set_combox_value(value=Location, keys=self.location)
        self.click(self.searchbutton)
        queryout_location = self.get_element_text(self.resulttable)
        location_without_gap = Location.strip()
        assert location_without_gap in queryout_location
        Log.info(
            "Directory Page, search location for search directory - passed")

    def search_SearchDirectory_All(self, Name, JobTitle, Location):
        """
        Test search name, job title and location on Search Directory
        """
        # Search name,job title and location at one time
        self.click(self.resetbutton)
        self.input_text(value=Name, keys=self.name)
        self.press_enter_key(self.name)
        self.sleep(2)
        self.set_combox_value(value=JobTitle, keys=self.jobtitle)
        self.sleep(2)
        self.set_combox_value(value=Location, keys=self.location)
        self.sleep(2)
        self.click(self.searchbutton)
        self.driver.implicitly_wait(5)
        enter_name = self.get_element_attribute(self.name, "Value")
        queryout_name = self.get_element_text(self.resulttable)
        assert enter_name in queryout_name
        queryout_jobtitle = self.get_element_text(self.resulttable)
        assert JobTitle in queryout_jobtitle
        queryout_location = self.get_element_text(self.resulttable)
        location_without_gap = Location.strip()
        assert location_without_gap in queryout_location
        Log.info(
            "Directory Page, search name, title, location for search directory - passed"
        )

    def search_SearchDirectory_No(self, Name, JobTitle, Location):
        """
        Test search name, job title and location on Search Directory
        """
        self.click(self.resetbutton)
        self.input_text(value=Name, keys=self.name)
        self.press_enter_key(self.name)
        self.sleep(2)
        self.set_combox_value(value=JobTitle, keys=self.jobtitle)
        self.sleep(2)
        self.set_combox_value(value=Location, keys=self.location)
        self.sleep(2)
        self.click(self.searchbutton)
        self.driver.implicitly_wait(5)
        self.is_element_visible(xpath=self.No_records_Found)
        queryout_info = self.get_element_text(self.No_records_Found)
        assert queryout_info == "No Records Found"
        Log.info(
            "Directory Page, search name, job title and location, no records found - passed"
        )
예제 #12
0
 def test_add_employee(self):
     self.addemployee = AddEmployee(self.driver)
     self.addemployee.add_user_employee(self.f_name, self.l_name)
예제 #13
0
 def create_employee(self, first_name, last_name):
     """
     Go to PIM, create a new employee
     """
     self.addemployee = AddEmployee(self.driver)
     self.addemployee.add_user_employee(first_name, last_name)
예제 #14
0
class AddLeaveEntitlement(Leave):
    """
    Add leave entitlements and Employee Entitlements pages main components
    """
    employee_name = ("id", "entitlements_employee_empName")
    leave_type = ("id", "entitlements_leave_type")
    leave_period = ("id", "period")
    entitlement = ("id", "entitlements_entitlement")
    save_btn = ("id", "btnSave")
    cancel_btn = ("id", "btnCancel")
    search_btn = ("id", "searchBtn")
    multiple_employee_checkbox = ("id", "entitlements_filters_bulk_assign")
    location = ("id", "entitlements_filters_location")
    sub_unit = ("id", "entitlements_filters_subunit")
    confirm_btn = ("id", "dialogUpdateEntitlementConfirmBtn")
    match_btn = ("id", "dialogConfirmBtn")
    checkbox_all = ("id", "ohrmList_chkSelectAll")
    add_btn = ("id", "btnAdd")
    delete_btn = ("id", "btnDelete")
    dialog_ok_btn = ("id", "dialogDeleteBtn")

    cancel_confirm_btn = ("xpath", "//input[@value='Cancel']")
    search_title = ("xpath", "//h1[text()='Leave Entitlements']")
    no_result = ("xpath", "//td[text()='No Records Found']")
    add_title = ("xpath", "//h1[text()='Add Leave Entitlement']")
    match_title = ("xpath", "//h3[text()='OrangeHRM - Matching Employees']")
    confirm_title = ("xpath",
                     "//h3[text()='OrangeHRM - Confirmation Required']")

    search_table_element = "//div[@id='tableWrapper']/table/tbody/tr[1]"

    def __init__(self, browser):
        super(AddLeaveEntitlement, self).__init__(browser)

    def select_menu(self):
        """
        Go to Add Entitlements page
        """
        self.switch_main_menu("leave")
        self.click_menu("Entitlements")
        self.click_menu("Add Entitlements")
        self.sleep(2)
        Log.info("Arrive Add Entitlements page")

    def create_employee(self, first_name, last_name):
        """
        Go to PIM, create a new employee
        """
        self.addemployee = AddEmployee(self.driver)
        self.addemployee.add_user_employee(first_name, last_name)

    def delete_employee(self, first_name, last_name):
        """
        Go to PIM, delete an employee
        """
        self.employeelist = EmployeeList(self.driver)
        self.employeelist.delete_employee(first_name + " " + last_name)

    def modify_leave_period(self, start_month, start_date):
        """
        Go to Leave - Configure to modify leave period
        """
        self.leaveperiod = LeavePeriod(self.driver)
        self.leaveperiod.edit_LeavePeriod()
        self.leaveperiod.select_StartMonth(start_month)
        self.leaveperiod.select_StartDate(start_date)
        self.leaveperiod.save_LeavePeriod()

    def input_employee_name(self, name):
        """
        Input employee name
        """
        self.clear_text(self.employee_name)
        self.input_text(name, self.employee_name)
        self.press_enter_key(self.employee_name)
        self.sleep(1)

    def select_type_period(self, leave_type, period):
        """
        Select leave type,period and entitlement
        """
        self.set_combox_value(leave_type, self.leave_type)
        self.set_combox_value(period, self.leave_period)

    def input_entitlement(self, entitlement):
        """
        Input entitlement
        """
        self.clear_text(self.entitlement)
        self.input_text(entitlement, self.entitlement)

    def save(self):
        """
        Click save button and confirm if updating dialog pops up
        """
        self.click(self.save_btn)
        self.sleep(3)
        assert self.element_is_displayed(self.search_title)
        Log.info("Save the new leave successfully")

    def cancel(self):
        """
        Click cancel button
        """
        self.click(self.cancel_btn)
        self.sleep(3)
        assert self.element_is_displayed(self.search_title)
        Log.info("Cancel to add new leave")

    def save_and_match(self):
        """
        Click save button and confirm on matching dialog
        """
        self.click(self.save_btn)
        self.sleep(3)

        self.wait_unit_el_present(self.match_title)
        self.click(self.match_btn)
        assert self.element_is_displayed(self.search_title)
        Log.info("Save the new leave for multiple employees successfully")

    def click_search_btn(self):
        """
        Click search button
        """
        self.click(self.search_btn)
        self.sleep(3)

    def click_multiple_employee(self):
        """
        Click add to multiple employees button
        """
        self.click(self.multiple_employee_checkbox)
        assert self.element_is_displayed(self.location)
        assert self.element_is_displayed(self.sub_unit)

    def input_location_unit(self, location, unit):
        """
        Input location and sub unit information
        """
        self.set_combox_value(location, self.location)
        self.set_combox_value(unit, self.sub_unit)

    def verify_no_record(self):
        """
        Verify no record in search table
        """
        assert self.element_is_displayed(self.no_result)
        Log.info("No new leave is added")

    def verify_new_leave(self, leave_period, entitlement):
        """
        Verify search table result for leave type not All
        """
        assert "Added" == self.get_element_text(
            ("xpath", self.search_table_element + "/td[2]")).encode("utf-8")
        assert leave_period.split(" - ")[0] == \
               self.get_element_text(("xpath", self.search_table_element + "/td[3]")).encode("utf-8")
        assert leave_period.split(" - ")[1] == \
               self.get_element_text(("xpath", self.search_table_element + "/td[4]")).encode("utf-8")
        assert '{:.2f}'.format(float(entitlement)) == \
               self.get_element_text(("xpath", self.search_table_element + "/td[5]")).encode("utf-8")
        Log.info("Add new leave entitlement successfully")

    def click_add_btn(self):
        """
        Click Add button to switch to Add Entitlements page
        """
        self.click(self.add_btn)
        self.wait_unit_el_present(self.add_title)

    def delete_leave_cancel(self):
        """
        Find record in table, delete then cancel
        """
        self.click(self.checkbox_all)
        self.click(self.delete_btn)
        self.wait_unit_el_present(self.confirm_title)
        self.click(self.cancel_confirm_btn)
        self.wait_unit_el_present(self.search_title)
        Log.info("Cancel to delete leave entitlements")

    def delete_all_leave(self):
        """
        Find all records in table and delete
        """
        self.click(self.checkbox_all)
        self.click(self.delete_btn)
        self.wait_unit_el_present(self.confirm_title)
        self.click(self.dialog_ok_btn)
        Log.info("Delete leave entitlements successfully")
예제 #15
0
 def delete_employee(self, last_name):
     """
     Go to PIM, delete an employee
     """
     self.pim = AddEmployee(self.driver)
     self.pim.delete_employee(last_name)
예제 #16
0
class Users(Admin):
    """
    User page main components
    """
    user_add_btn = ("ID", "btnAdd")
    user_role_field = ("ID", "systemUser_userType")
    user_employee_name_field = ("ID", "systemUser_employeeName_empName")
    user_name_field = ("ID", "systemUser_userName")
    user_status_field = ("ID", "systemUser_status")
    user_pwd_field = ("ID", "systemUser_password")
    user_confirm_pwd_field = ("ID", "systemUser_confirmPassword")
    user_save_btn = ("ID", "btnSave")
    user_search_field = ("ID", "searchSystemUser_userName")
    user_search_btn = ("ID", "searchBtn")
    user_reset_btn = ("ID", "resetBtn")
    user_delete_btn = ("ID", "btnDelete")
    dialog_delete_btn = ('ID', 'dialogDeleteBtn')
    delete_record = (
        "xpath", "//a[contains(text(),'dorothy_012345')]/../../td[1]/input")
    user_names = ("xpath", "//tbody/tr/td[2]/a")
    search_flag = ('link_text', 'dorothy_012345')
    success_flag = ("xpath", "//*[@class='message success fadable']")
    search_name = None
    edit_record = ('link_text', 'test1')
    user_edit_btn = ("ID", "btnSave")
    search_link_text = "{}"
    delete_tr = "//*[text()='{}']/../../td[1]"

    def __init__(self, browser):
        super(Users, self).__init__(browser)

    def create_employee(self, first_name, last_name):
        """
        Go to PIM, check employee and create a new employee
        """
        self.pim = AddEmployee(self.driver)
        self.sleep(3)
        self.pim.add_user_employee(first_name, last_name)
        Log.info("Arrive Add Employee page")

    def switch_menu(self):
        """
        Back to Users page
        """
        self.click_menu("Admin")
        self.click_menu("User Management")
        self.click_menu("Users")
        Log.info("Arrive System Users page")

    def check_if_user_exist(self, uname):
        """
        Check if user exist
        """
        names = self.get_elements_texts(self.user_names)
        for name in names:
            if uname == name:
                return uname
                break
        return None

    def add_user(self, user_role, employee_name, user_name, user_status,
                 user_password):
        """
        Add user
        """
        Log.info("Start to add user")
        check_user_name = self.check_if_user_exist(user_name)
        if check_user_name is None:
            self.click(self.user_add_btn)
            self.set_combox_value(user_role, self.user_role_field)
            self.clear_text(self.user_employee_name_field)
            self.input_text(employee_name, self.user_employee_name_field)
            self.clear_text(self.user_name_field)
            self.input_text(user_name, self.user_name_field)
            self.set_combox_value(user_status, self.user_status_field)
            self.clear_text(self.user_pwd_field)
            self.input_text(user_password, self.user_pwd_field)
            self.clear_text(self.user_confirm_pwd_field)
            self.input_text(user_password, self.user_confirm_pwd_field)
            self.sleep(2)
            self.click(self.user_save_btn)
            assert "Successfully Saved" in self.get_element_text(
                self.success_flag)

    def search_user(self, user_name):
        """
        search user record
        """
        Log.info("Start to search user")
        self.clear_text(self.user_search_field)
        self.sleep(3)
        self.input_text(user_name, self.user_search_field)
        self.sleep(3)
        self.click(self.user_search_btn)
        self.sleep(3)
        self.search_name = self.get_element_text(self.search_flag)
        return self.search_name

    def delete_user(self, deleted_user_name):
        """
        delete user
        """
        Log.info("Start to delete user")
        check_user_name = self.check_if_user_exist(deleted_user_name)
        if check_user_name == deleted_user_name:
            self.click(self.delete_record)
            self.sleep(3)
            self.click(self.user_delete_btn)
            self.sleep(3)
            self.click(self.dialog_delete_btn)
            assert "Successfully Deleted" in self.get_element_text(
                self.success_flag)
            Log.info("Records are deleted Successfully!")

    def edit_users(self, edit_name):
        """
        edit user
        """
        Log.info("Start to edit user")
        self.click(self.edit_record)
        self.sleep(3)
        self.click(self.user_edit_btn)
        self.clear_text(self.user_name_field)
        self.input_text(edit_name, self.user_name_field)
        self.sleep(3)
        self.click(self.user_edit_btn)
        assert "Successfully Updated" in self.get_element_text(
            self.success_flag)
        Log.info("Edit Successfully")

    def update_user(self, user_name_value, updated_user_name):
        """
        update searched record
        """
        self.click(
            ["LINK_TEXT",
             self.search_link_text.format(user_name_value)])
        self.click(self.user_edit_btn)
        self.clear_text(self.user_name_field)
        self.input_text(updated_user_name, self.user_name_field)
        self.click(self.user_edit_btn)
        assert self.get_element_text(
            ["LINK_TEXT",
             self.search_link_text.format(updated_user_name)]) is not None

    def search(self, user_name):
        """
        search user record
        """
        Log.info("search user")
        self.clear_text(self.user_search_field)
        self.input_text(user_name, self.user_search_field)
        self.click(self.user_search_btn)
        assert self.get_element_text(
            ["LINK_TEXT", self.search_link_text.format(user_name)]) is not None

    def delete(self, update_user_name):
        """
        Delete user
        """

        Log.info("Start To Delete")
        tr = ("XPATH", self.delete_tr.format(update_user_name))
        self.click(tr)
        self.click(self.user_delete_btn)
        self.click(self.dialog_delete_btn)
        assert self.get_element_text(
            ["LINK_TEXT",
             self.search_link_text.format(update_user_name)]) is None
        Log.info("Delete Successfully")
예제 #17
0
class AssignLeave(Leave):
    """
    Assign leave page main components
    """
    employee_name = ("id", "assignleave_txtEmployee_empName")
    leave_type = ("id", "assignleave_txtLeaveType")
    leave_blance = ("id", "assignleave_leaveBalance")
    view_detail = ("id", "leaveBalance_details_link")
    from_date = ("id", "assignleave_txtFromDate")
    to_date = ("id", "assignleave_txtToDate")
    partial_days = ("id", "assignleave_partialDays")
    duration = ("id", "assignleave_duration_duration")
    first_duration = ("id", "assignleave_firstDuration_duration")
    time_from = ("id", "assignleave_firstDuration_time_from")
    time_to = ("id", "assignleave_firstDuration_time_to")
    comment = ("id", "assignleave_txtComment")
    assign_btn = ("id", "assignBtn")
    popup_employee_name = ("id", "popup_emp_name")
    popup_leave_type = ("id", "popup_leave_type")
    blance_day = ("id", "balance_as_of")
    scheduled_day = ("id", "balance_scheduled")
    balance_total = ("id", "balance_total")
    confirm_btn = ("id", "confirmOkButton")
    multiperiod_employee = ("id", "multiperiod_emp_name")
    multiperiod_type = ("id", "multiperiod_leave_type")

    view_detail_xpath = ("xpath","//a[@id='leaveBalance_details_link']")
    partial_days_xpath = ("xpath", "//select[@id='assignleave_partialDays']")
    confirm_title = ("xpath", "//h3[text()='OrangeHRM - Confirm Leave Assignment']")
    details_OK_btn = ("xpath", "//div[@id='balance_details']/div[3]/input[@id='closeButton']")
    multiperiod_OK_btn = ("xpath", "//div[@id='multiperiod_balance']/div[3]/input[@id='closeButton']")
    overlapping_title = ("xpath","//h1[text()='Overlapping Leave Request Found']")

    overlapping_table_xpath = "//div[@class='inner']/table/tbody/tr[1]"
    leave_date_xpath = "//div[@id='multiperiod_balance']/div[@class='modal-body']/table/tbody"

    def __init__(self, browser):
        super(AssignLeave, self).__init__(browser)

    def select_menu(self):
        """
        Go to Assign Leave page
        """
        self.switch_main_menu("leave")
        self.click_menu("Assign Leave")
        Log.info("Arrive Assign Leave page")

    def create_employee(self, first_name, last_name):
        """
        Go to PIM, create a new employee
        """
        self.addemployee = AddEmployee(self.driver)
        self.addemployee.add_user_employee(first_name, last_name)

    def delete_employee(self, first_name, last_name):
        """
        Go to PIM, delete an employee
        """
        self.employeelist = EmployeeList(self.driver)
        self.employeelist.delete_employee(first_name + " " + last_name)

    def select_name_type(self, name, leave_type):
        """
        Select Employee Name and Leave Type
        """
        self.clear_text(self.employee_name)
        self.input_text(name,self.employee_name)
        self.press_enter_key(self.employee_name)
        self.set_combox_value(leave_type, self.leave_type)
        self.wait_unit_el_present(self.view_detail_xpath)

    def input_samedate_duration_comment(self, date, duration, comment):
        """
        Input From Date, To Date, Duration and comment
        """
        self.clear_text(self.from_date)
        self.input_text(date, self.from_date)
        self.press_enter_key(self.from_date)
        self.clear_text(self.to_date)
        self.input_text(date, self.to_date)
        self.press_enter_key(self.to_date)
        self.set_combox_value(duration, self.duration)
        self.input_text(comment, self.comment)
        self.sleep(2)

    def input_multiperiod_partial(self, datefrom, dateto, partialdays):
        """
        Input From Date, To Date and partial days
        """
        self.clear_text(self.from_date)
        self.input_text(datefrom, self.from_date)
        self.press_enter_key(self.from_date)
        self.clear_text(self.to_date)
        self.input_text(dateto, self.to_date)
        self.press_enter_key(self.to_date)
        self.wait_unit_el_present(self.partial_days_xpath)
        self.set_combox_value(partialdays, self.partial_days)

    def input_duration_time_comment(self, duration, timefrom, timeto, comment):
        """
        Input duration, time and comment
        """
        self.set_combox_value(duration, self.first_duration)
        self.set_combox_value(timefrom, self.time_from)
        self.set_combox_value(timeto, self.time_to)
        self.input_text(comment, self.comment)
        self.sleep(2)

    def assign(self):
        """
        Assign and confirm if confirm dialog pops up
        """
        self.click(self.assign_btn)
        element = self.get_element(self.confirm_title)
        if element.is_displayed():
            self.click(self.confirm_btn)

        self.wait_unit_el_present(self.view_detail_xpath)
        Log.info("Assign new leave")

    def verify_balance_samedate(self, employee, leave_type, date):
        """
        Open view details and verify leave balance for same date set
        """
        self.click(self.view_detail)
        self.wait_unit_el_present(self.details_OK_btn)

        assert employee == self.get_element_text(self.popup_employee_name).encode("utf-8")
        assert leave_type == self.get_element_text(self.popup_leave_type).encode("utf-8")
        assert date == self.get_element_text(self.blance_day).encode("utf-8")
        assert "-1.00" == self.get_element_text(self.balance_total).encode("utf-8")
        assert self.get_element_text(self.leave_blance)[:5] == \
               self.get_element_text(self.balance_total).encode("utf-8")
        self.click(self.details_OK_btn)
        self.sleep(1)
        Log.info("Assign leave for same date successfully")

    def verify_balance_multiperiod(self, employee, leave_type, datefrom, dateto):
        """
        Open view details and verify leave balance for different date set
        """
        assert "Balance not sufficient" == self.get_element_text(self.view_detail)
        self.click(self.view_detail)
        self.wait_unit_el_present(self.multiperiod_OK_btn)

        assert employee == self.get_element_text(self.multiperiod_employee).encode("utf-8")
        assert leave_type == self.get_element_text(self.multiperiod_type).encode("utf-8")
        assert datefrom == self.get_element_text(("xpath", self.leave_date_xpath + "/tr[1]/td[3]")).encode("utf-8")
        assert dateto == self.get_element_text(("xpath", self.leave_date_xpath + "/tr[2]/td[3]")).encode("utf-8")
        assert "-3.00" == self.get_element_text(self.leave_blance)[:5]
        assert self.get_element_text(self.leave_blance)[:5] == \
               self.get_element_text(("xpath", self.leave_date_xpath + "/tr[1]/td[2]")).encode("utf-8")
        self.sleep(1)
        self.click(self.multiperiod_OK_btn)
        Log.info("Assign leave for different date successfully")

    def check_overlapping(self, date, leave_type):
        """
        Verify overlapping
        """
        assert self.get_element(self.overlapping_title).is_displayed()
        assert "-1.00" == self.get_element_text(self.leave_blance)[:5]
        assert date == self.get_element_text(("xpath", self.overlapping_table_xpath+ "/td[1]")).encode("utf-8")
        assert leave_type == self.get_element_text(("xpath",
                                                    self.overlapping_table_xpath + "/td[3]")).encode("utf-8")
        Log.info("Overlapping is correct")