Exemplo n.º 1
0
 def __init__(self, driver):
     self.driver = driver
     self.link_add_work_position = self.driver.find_element(
         *NewCompany5PageLocators.link_add_work_position)
     self.button_finish = self.driver.find_element(
         *NewCompany5PageLocators.button_finish)
     self.waiter = Waiter(self.driver)
Exemplo n.º 2
0
class SearchPage:
    def __init__(self, driver):
        self.driver = driver
        self.button_show_search_form = self.driver.find_element(*SearchPageLocators.button_show_search_form)
        self.field_search = self.driver.find_element(*SearchPageLocators.field_search)
        self.button_search = self.driver.find_element(*SearchPageLocators.button_search)
        self.waiter = Waiter(self.driver, locator=SearchPageLocators.wrap)

    def __call__(self):
        self.radio_scope_users = self.driver.find_element(*SearchPageLocators.radio_scope_users)

    def fill_field_search(self, value):
        time.sleep(0.5)
        self.field_search.clear()
        self.field_search.send_keys(value)

    def find_user(self, value):
        self.__call__()
        self.button_show_search_form.click()
        self.waiter.wait_attribute_to_be_open()
        self.radio_scope_users.click()
        self.fill_field_search(value)
        self.button_search.click()

    def find_user_basic(self, value):
        self.button_show_search_form.click()
        self.waiter.wait_attribute_to_be_open()
        self.fill_field_search(value)
        self.button_search.click()
Exemplo n.º 3
0
 def __init__(self, driver):
     self.driver = driver
     self.link_add_organization_unit = self.driver.find_element(
         *NewCompany4PageLocators.link_add_organization_unit)
     self.button_continue = self.driver.find_element(
         *NewCompany4PageLocators.button_continue)
     self.waiter = Waiter(self.driver)
 def __init__(self, driver):
     self.driver = driver
     self.link_add_benefits = self.driver.find_element(
         *ChangeEmployment2PageLocators.link_add_benefits)
     self.button_save_and_continue = self.driver.find_element(
         *ChangeEmployment2PageLocators.button_save_and_continue)
     self.waiter = Waiter(self.driver)
class MenuAttendancePage(MenuMasterPage):
    def __init__(self, driver):
        self.driver = driver
        self.menu = menu['attendance']
        self.main = self.driver.find_element(*self.fill_tuple(
            MenuAttendancePageLocators.main, self.menu['main']))
        self.waiter = Waiter(self.driver,
                             locator=self.fill_tuple(
                                 MenuAttendancePageLocators.main,
                                 self.menu['main']))

    def __call__(self):
        self.__init__(self.driver)
        return self

    def start(self):
        self.main.click()
        self.waiter.wait_attribute_to_be_open()

    def click_link_plan(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuAttendancePageLocators.link_plan,
                             self.menu['plan']['link'])).click()
        super().verify_page(self.driver, self.menu['plan'])

    def click_link_closing(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuAttendancePageLocators.link_closing,
                             self.menu['closing']['link'])).click()
        super().verify_page(self.driver, self.menu['closing'])
Exemplo n.º 6
0
 def __init__(self, driver, employee_instance):
     self.driver = driver
     self.employee_instance = employee_instance
     self.dropdown_employment = self.driver.find_element(
         *AttendanceNewShiftPageLocators.dropdown_employment)
     self.field_date_from = self.driver.find_element(
         *AttendanceNewShiftPageLocators.field_date_from)
     self.field_time_from = self.driver.find_element(
         *AttendanceNewShiftPageLocators.field_time_from)
     self.field_time_to = self.driver.find_element(
         *AttendanceNewShiftPageLocators.field_time_to)
     self.dropdown_breaks = self.driver.find_element(
         *AttendanceNewShiftPageLocators.dropdown_breaks)
     self.dropdown_repetition = self.driver.find_element(
         *AttendanceNewShiftPageLocators.dropdown_repetition)
     self.dropdown_color = self.driver.find_element(
         *AttendanceNewShiftPageLocators.dropdown_color)
     self.field_name = self.driver.find_element(
         *AttendanceNewShiftPageLocators.field_name)
     self.field_note = self.driver.find_element(
         *AttendanceNewShiftPageLocators.field_note)
     self.button_save = self.driver.find_element(
         *AttendanceNewShiftPageLocators.button_save)
     self.link_close = self.driver.find_element(
         *AttendanceNewShiftPageLocators.link_close)
     self.waiter = Waiter(self.driver)
    def __init__(self, driver, employee_instance):
        self.driver = driver
        self.employee_instance = employee_instance

        self.button_save = self.driver.find_element(
            *AttendanceNewAbsencePageLocators.button_save)
        self.link_close = self.driver.find_element(
            *AttendanceNewAbsencePageLocators.link_close)
        self.waiter = Waiter(self.driver)
Exemplo n.º 8
0
 def __init__(self, driver):
     self.driver = driver
     self.menu = menu['employees']
     self.main = self.driver.find_element(*self.fill_tuple(
         MenuEmployeesPageLocators.main, self.menu['main']))
     self.waiter = Waiter(self.driver,
                          locator=self.fill_tuple(
                              MenuEmployeesPageLocators.main,
                              self.menu['main']))
 def __init__(self, driver):
     self.driver = driver
     self.menu = menu['attendance']
     self.main = self.driver.find_element(*self.fill_tuple(
         MenuAttendancePageLocators.main, self.menu['main']))
     self.waiter = Waiter(self.driver,
                          locator=self.fill_tuple(
                              MenuAttendancePageLocators.main,
                              self.menu['main']))
Exemplo n.º 10
0
 def __init__(self, driver, employee_instance):
     self.driver = driver
     self.employee_instance = employee_instance
     self.dropdown_attendance_company_select = self.driver.find_element(
         *AttendancePageLocators.dropdown_attendance_company_select)
     self.link_new_absence = self.driver.find_element(
         *AttendancePageLocators.link_new_absence)
     self.link_new_shift = self.driver.find_element(
         *AttendancePageLocators.link_new_shift)
     self.waiter = Waiter(self.driver)
Exemplo n.º 11
0
 def __init__(self, driver):
     self.driver = driver
     self.dropdown_duration_months = self.driver.find_element(*NewEmployment2PageLocators.dropdown_duration_months)
     self.dropdown_trial_period_months = self.driver.find_element(*NewEmployment2PageLocators.dropdown_trial_period_months)
     self.dropdown_shift_type = self.driver.find_element(*NewEmployment2PageLocators.dropdown_shift_type)
     self.field_working_hours_per_week = self.driver.find_element(*NewEmployment2PageLocators.field_working_hours_per_week)
     self.radio_working_hours_type = self.driver.find_elements(*NewEmployment2PageLocators.radio_working_hours_type)
     self.link_add_benefits = None
     self.field_basic_salary = self.driver.find_element(*NewEmployment2PageLocators.field_basic_salary)
     self.button_save_and_continue = self.driver.find_element(*NewEmployment2PageLocators.button_save_and_continue)
     self.waiter = Waiter(self.driver)
Exemplo n.º 12
0
class MenuEmployeesPage(MenuMasterPage):
    def __init__(self, driver):
        self.driver = driver
        self.menu = menu['employees']
        self.main = self.driver.find_element(*self.fill_tuple(
            MenuEmployeesPageLocators.main, self.menu['main']))
        self.waiter = Waiter(self.driver,
                             locator=self.fill_tuple(
                                 MenuEmployeesPageLocators.main,
                                 self.menu['main']))

    def __call__(self):
        self.__init__(self.driver)
        return self

    def start(self):
        self.main.click()
        self.waiter.wait_attribute_to_be_open()

    def click_link_employees(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuEmployeesPageLocators.link_employees,
                             self.menu['employees']['link'])).click()
        super().verify_page(self.driver, self.menu['employees'])

    def click_link_document_definitions(self):
        self.start()
        self.main.find_element(*self.fill_tuple(
            MenuEmployeesPageLocators.link_document_definitions,
            self.menu['documentDefinition']['link'])).click()
        super().verify_page(self.driver, self.menu['documentDefinition'])

    def click_link_changes(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuEmployeesPageLocators.link_changes,
                             self.menu['changes']['link'])).click()
        super().verify_page(self.driver, self.menu['changes'])

    def click_link_changes_new(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuEmployeesPageLocators.link_changes_new,
                             self.menu['changesNew']['link'])).click()
        super().verify_page(self.driver, self.menu['changesNew'])

    def click_link_documents_overview(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuEmployeesPageLocators.link_documents_overview,
                             self.menu['documentOverview']['link'])).click()
        super().verify_page(self.driver, self.menu['documentOverview'])
Exemplo n.º 13
0
class MenuSystemPage(MenuMasterPage):
    def __init__(self, driver):
        self.driver = driver
        self.menu = menu['system']
        self.waiter = Waiter(self.driver,
                             locator=self.fill_tuple(
                                 MenuSystemPageLocators.main,
                                 self.menu['main']))
        self.main = self.driver.find_element(
            *self.fill_tuple(MenuSystemPageLocators.main, self.menu['main']))

    def __call__(self):
        self.__init__(self.driver)
        return self

    def start(self):
        self.main.click()
        self.waiter.wait_attribute_to_be_open()

    def click_link_users(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuSystemPageLocators.link_users,
                             self.menu['users']['link'])).click()
        super().verify_page(self.driver, self.menu['users'])

    def click_link_roles(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuSystemPageLocators.link_roles,
                             self.menu['roles']['link'])).click()
        super().verify_page(self.driver, self.menu['roles'])

    def click_link_companies(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuSystemPageLocators.link_companies,
                             self.menu['companies']['link'])).click()
        super().verify_page(self.driver, self.menu['companies'])

    def click_link_system_settings(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuSystemPageLocators.link_system_settings,
                             self.menu['systemSettings']['link'])).click()
        super().verify_page(self.driver, self.menu['systemSettings'])

    def click_link_licence(self):
        self.start()
        self.main.find_element(
            *self.fill_tuple(MenuSystemPageLocators.link_licence,
                             self.menu['licence']['link'])).click()
        super().verify_page(self.driver, self.menu['licence'])
Exemplo n.º 14
0
 def __init__(self, driver):
     self.driver = driver
     self.radio_personal_number_format = self.driver.find_elements(
         *NewCompany2PageLocators.radio_personal_number_format)
     self.radio_personal_number_editable = self.driver.find_elements(
         *NewCompany2PageLocators.radio_personal_number_editable)
     self.field_minimal_personal_number = self.driver.find_element(
         *NewCompany2PageLocators.field_minimal_personal_number)
     self.field_balancing_period = self.driver.find_element(
         *NewCompany2PageLocators.field_balancing_period)
     self.radio_balancing_period_units = self.driver.find_elements(
         *NewCompany2PageLocators.radio_balancing_period_units)
     self.field_balancing_period_starts_when = self.driver.find_element(
         *NewCompany2PageLocators.field_balancing_period_starts_when)
     self.radio_having_benefits = self.driver.find_elements(
         *NewCompany2PageLocators.radio_having_benefits)
     self.link_add_benefits = self.driver.find_element(
         *NewCompany2PageLocators.link_add_benefits)
     self.button_save_and_continue = self.driver.find_element(
         *NewCompany2PageLocators.button_save_and_continue)
     self.waiter = Waiter(self.driver)
class AttendanceNewAbsencePage:
    def __init__(self, driver, employee_instance):
        self.driver = driver
        self.employee_instance = employee_instance

        self.button_save = self.driver.find_element(
            *AttendanceNewAbsencePageLocators.button_save)
        self.link_close = self.driver.find_element(
            *AttendanceNewAbsencePageLocators.link_close)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.__init__(self.driver)

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")

    # --------------------------------------------------------------------------------------------------------
    def fill_form_positive(self, absence):
        try:
            pass
        except Exception as e:
            self.click_link_close()
            assert False, "Nepovedlo se přidat novou nepřítomnost: " + str(e)
        else:
            self.click_button_save()
        try:
            self.waiter.wait_for_modal("close")
        except TimeoutException:
            self()
            self.click_link_close()
            assert False, "Nepovedlo se přidat novou nepřítomnost!"
Exemplo n.º 16
0
class NewCompany2Page(BasePage):

    reward_types = {
        "exact-amount": NewCompany2PageLocators.field_exact_amount,
        "hourly-bonus": NewCompany2PageLocators.field_hourly_amount,
        "percentual-bonus": NewCompany2PageLocators.field_percentual_amount
    }

    def __init__(self, driver):
        self.driver = driver
        self.radio_personal_number_format = self.driver.find_elements(
            *NewCompany2PageLocators.radio_personal_number_format)
        self.radio_personal_number_editable = self.driver.find_elements(
            *NewCompany2PageLocators.radio_personal_number_editable)
        self.field_minimal_personal_number = self.driver.find_element(
            *NewCompany2PageLocators.field_minimal_personal_number)
        self.field_balancing_period = self.driver.find_element(
            *NewCompany2PageLocators.field_balancing_period)
        self.radio_balancing_period_units = self.driver.find_elements(
            *NewCompany2PageLocators.radio_balancing_period_units)
        self.field_balancing_period_starts_when = self.driver.find_element(
            *NewCompany2PageLocators.field_balancing_period_starts_when)
        self.radio_having_benefits = self.driver.find_elements(
            *NewCompany2PageLocators.radio_having_benefits)
        self.link_add_benefits = self.driver.find_element(
            *NewCompany2PageLocators.link_add_benefits)
        self.button_save_and_continue = self.driver.find_element(
            *NewCompany2PageLocators.button_save_and_continue)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.driver = self.driver
        self.field_name = self.driver.find_element(
            *NewCompany2PageLocators.field_name)
        self.field_localized_name_cs = self.driver.find_element(
            *NewCompany2PageLocators.field_localized_name_cs)
        self.field_localized_name_en = self.driver.find_element(
            *NewCompany2PageLocators.field_localized_name_en)
        self.field_wage_item_code = self.driver.find_element(
            *NewCompany2PageLocators.field_wage_item_code)
        self.dropdown_reward_type = self.driver.find_element(
            *NewCompany2PageLocators.dropdown_reward_type)
        self.field_exact_amount = self.driver.find_element(
            *NewCompany2PageLocators.field_exact_amount)
        self.radio_for_all_organization_units = self.driver.find_elements(
            *NewCompany2PageLocators.radio_for_all_organization_units)
        self.radio_for_all_work_positions = self.driver.find_elements(
            *NewCompany2PageLocators.radio_for_all_work_positions)
        self.button_save = self.driver.find_element(
            *NewCompany2PageLocators.button_save)
        self.link_close = self.driver.find_element(
            *NewCompany2PageLocators.link_close)

    def select_radio_personal_number_format(self, os_format):
        click_radio_by_value(self.radio_personal_number_format, os_format)

    def select_radio_personal_number_editable(self, os_editable):
        click_radio_by_value(self.radio_personal_number_editable, os_editable)

    def fill_field_minimal_personal_number(self, os_min):
        self.field_minimal_personal_number.clear()
        self.field_minimal_personal_number.send_keys(os_min)

    def fill_field_balancing_period(self, balancing_period):
        self.field_balancing_period.clear()
        self.field_balancing_period.send_keys(balancing_period)

    def select_radio_balancing_period_units(self, balancing_period_units):
        click_radio_by_value(self.radio_balancing_period_units,
                             balancing_period_units)

    def fill_field_balancing_period_starts_when(self,
                                                balancing_period_starts_when):
        self.field_balancing_period_starts_when.clear()
        self.field_balancing_period_starts_when.send_keys(
            balancing_period_starts_when)
        self.field_balancing_period_starts_when.send_keys(Keys.ENTER)

    def select_radio_having_benefits(self, benefits):
        value = "0" if len(benefits) == 0 else "1"
        click_radio_by_value(self.radio_having_benefits, value)

    def click_link_add_benefits(self):
        time.sleep(0.5)
        self.link_add_benefits.click()
        self.waiter.wait_for_modal("open")

        # BENEFITS
    def fill_field_name(self, name):
        self.field_name.clear()
        self.field_name.send_keys(name)

    def fill_field_localized_name_cs(self, localized_name_cs):
        self.field_localized_name_cs.clear()
        self.field_localized_name_cs.send_keys(localized_name_cs)

    def fill_field_localized_name_en(self, localized_name_en):
        self.field_localized_name_en.clear()
        self.field_localized_name_en.send_keys(localized_name_en)

    def fill_field_wage_item_code(self, wage_item_code):
        self.field_wage_item_code.clear()
        self.field_wage_item_code.send_keys(wage_item_code)

    def fill_dropdown_reward_type(self, reward_type):
        select_dropdown_item(self.dropdown_reward_type, reward_type, "known")

    def fill_field_amount(self, reward_type, amount):
        if reward_type not in self.reward_types.keys():
            raise ValueError(
                "V testovacích datech je zadána neplatná hodnota parametru reward_type: "
                + reward_type)
        element = self.driver.find_element(*self.reward_types[reward_type])
        element.clear()
        element.send_keys(amount)

    def select_radio_for_all_organization_units(self,
                                                for_all_organization_units):
        click_radio_by_value(self.radio_for_all_organization_units,
                             for_all_organization_units)

    def select_radio_for_all_work_positions(self, for_all_work_positions):
        click_radio_by_value(self.radio_for_all_work_positions,
                             for_all_work_positions)

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")

    # --------------------------------------------------------------------------------------------------------------

    def click_button_save_and_continue(self):
        self.button_save_and_continue.click()

    def fill_form(self, company2):
        self.fill_field_balancing_period(company2['balancing_period'])
        self.select_radio_balancing_period_units(
            company2['balancing_period_units'])
        self.fill_field_balancing_period_starts_when(
            company2['balancing_period_starts_when'])
        self.select_radio_having_benefits(company2['benefits'])
        if len(company2['benefits']) > 0:
            for benefit in company2['benefits']:
                self.click_link_add_benefits()
                self()
                try:
                    self.fill_field_name(benefit['name'])
                    self.fill_field_wage_item_code(benefit['wage_item_code'])
                    self.fill_dropdown_reward_type(benefit['reward_type'])
                    self.fill_field_amount(benefit['reward_type'],
                                           benefit['amount'])
                    self.select_radio_for_all_organization_units(
                        benefit['for_all_organization_units'])
                    self.select_radio_for_all_work_positions(
                        benefit['for_all_work_positions'])
                except Exception as e:
                    self.click_link_close()
                    assert False, "Nepovedlo se přidat nový benefit: " + str(e)
                else:
                    self.click_button_save()
                try:
                    self.waiter.wait_for_modal("close")
                except TimeoutException:
                    self()
                    self.click_link_close()
                    assert False, "Nepovedlo se přidat nový benefit!"
        self.click_button_save_and_continue()

    def test_basic_positive(self, company2):
        self.fill_form(company2)
        assert self.screens['company'][
            "3"] in self.driver.current_url, "Nepovedlo se odeslat 2. část formuláře pro vytvoření nové společnosti!"
Exemplo n.º 17
0
class AttendanceNewShiftPage:
    def __init__(self, driver, employee_instance):
        self.driver = driver
        self.employee_instance = employee_instance
        self.dropdown_employment = self.driver.find_element(
            *AttendanceNewShiftPageLocators.dropdown_employment)
        self.field_date_from = self.driver.find_element(
            *AttendanceNewShiftPageLocators.field_date_from)
        self.field_time_from = self.driver.find_element(
            *AttendanceNewShiftPageLocators.field_time_from)
        self.field_time_to = self.driver.find_element(
            *AttendanceNewShiftPageLocators.field_time_to)
        self.dropdown_breaks = self.driver.find_element(
            *AttendanceNewShiftPageLocators.dropdown_breaks)
        self.dropdown_repetition = self.driver.find_element(
            *AttendanceNewShiftPageLocators.dropdown_repetition)
        self.dropdown_color = self.driver.find_element(
            *AttendanceNewShiftPageLocators.dropdown_color)
        self.field_name = self.driver.find_element(
            *AttendanceNewShiftPageLocators.field_name)
        self.field_note = self.driver.find_element(
            *AttendanceNewShiftPageLocators.field_note)
        self.button_save = self.driver.find_element(
            *AttendanceNewShiftPageLocators.button_save)
        self.link_close = self.driver.find_element(
            *AttendanceNewShiftPageLocators.link_close)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.__init__(self.driver)

    def fill_dropdown_shift_form_employment(self):
        id_employment = self.employee_instance.get_id_employment(
        ) + "--" + self.employee_instance.get_id()
        select_dropdown_item(self.dropdown_employment, id_employment,
                             "contains")

    def fill_field_shift_form_date_from(self, date_from):
        self.field_date_from.clear()
        self.field_date_from.send_keys(date_from)
        self.field_date_from.send_keys(Keys.ENTER)

    def fill_field_shift_form_time_from(self, time_from):
        self.field_time_from.clear()
        self.field_time_from.send_keys(time_from)
        self.field_time_from.send_keys(Keys.ENTER)

    def fill_field_shift_form_time_to(self, time_to):
        self.field_time_to.clear()
        self.field_time_to.send_keys(time_to)
        self.field_time_to.send_keys(Keys.ENTER)

    def fill_dropdown_shift_form_breaks(self, breaks):
        select_dropdown_item(self.dropdown_breaks, str(len(breaks)))
        for i, item in enumerate(breaks):
            break_from = self.driver.find_element_by_id(
                "shift_form_break_%s_from" % str(i))
            break_from.clear()
            break_from.send_keys(item['break_from'])
            break_from.send_keys(Keys.ENTER)
            break_to = self.driver.find_element_by_id(
                "shift_form_break_%s_to" % str(i))
            break_to.clear()
            break_to.send_keys(item['break_to'])
            break_to.send_keys(Keys.ENTER)

    def fill_dropdown_shift_form_repetition(self, shift_form_repetition):
        select_dropdown_item(self.dropdown_repetition, shift_form_repetition,
                             "known")

    def fill_dropdown_shift_form_color(self, shift_form_color):
        select_dropdown_item(self.driver, self.dropdown_color,
                             shift_form_color)

    def fill_field_shift_form_name(self, shift_form_name):
        self.field_name.clear()
        self.field_name.send_keys(shift_form_name)

    def fill_field_shift_form_note(self, shift_form_note):
        self.field_note.clear()
        self.field_note.send_keys(shift_form_note)

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close", param="shift")

    # --------------------------------------------------------------------------------------------------------
    def fill_form_positive(self, shift):
        try:
            self.fill_dropdown_shift_form_employment()
            self.fill_field_shift_form_date_from(shift['date_from'])
            self.fill_field_shift_form_time_from(shift['time_from'])
            self.fill_field_shift_form_time_to(shift['time_to'])
            self.fill_dropdown_shift_form_breaks(shift['breaks'])
            self.fill_dropdown_shift_form_repetition(shift['repetition'])
        except Exception as e:
            self.click_link_close()
            assert False, "Nepovedlo se přidat novou směnu: " + str(e)
        else:
            self.click_button_save()
        try:
            self.waiter.wait_for_modal("close", param="shift")
        except TimeoutException:
            self()
            self.click_link_close()
            assert False, "Nepovedlo se přidat novou směnu!"
Exemplo n.º 18
0
class AttendancePage:
    def __init__(self, driver, employee_instance):
        self.driver = driver
        self.employee_instance = employee_instance
        self.dropdown_attendance_company_select = self.driver.find_element(
            *AttendancePageLocators.dropdown_attendance_company_select)
        self.link_new_absence = self.driver.find_element(
            *AttendancePageLocators.link_new_absence)
        self.link_new_shift = self.driver.find_element(
            *AttendancePageLocators.link_new_shift)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.__init__(self.driver, self.employee_instance)

    def fill_dropdown_attendance_company_select(self, company_name):
        select_dropdown_item(self.dropdown_attendance_company_select,
                             company_name,
                             deselect=False)
        time.sleep(0.5)
        self()

    def click_link_new_absence(self):
        self.link_new_absence.click()
        self.waiter.wait_for_modal("open", param="absence")

    def click_link_new_shift(self):
        self.link_new_shift.click()
        self.waiter.wait_for_modal("open", param="shift")

    def test_basic_positive(self):
        attendance = self.employee_instance.get_attendance()
        self.fill_dropdown_attendance_company_select(attendance['company'])
        self.new_shift_positive(attendance['shifts'])
        self.new_absence_positive(attendance['absences'])

    def new_shift_positive(self, shifts):
        for item in shifts:
            self.click_link_new_shift()
            AttendanceNewShiftPage(
                self.driver, self.employee_instance).fill_form_positive(item)
            self.verify_new_record("shifts", item['date_from'])

    def new_absence_positive(self, absences):
        for item in absences:
            self.click_link_new_absence()
            AttendanceNewAbsencePage(
                self.driver, self.employee_instance).fill_form_positive(item)
            self.verify_new_record("absences", item['date_from'])

    def verify_new_record(self, param, day_str):
        if param not in ["shifts", "absences"]:
            raise ValueError("Parametr '" + str(param) + "' není platný!")
        while True:
            self()
            day = datetime.strptime(day_str, '%d.%m.%Y')
            current_week = self.driver.find_element_by_id(
                "calendar-date-current").text
            array = current_week.split(" - ")
            day_from = datetime.strptime(array[0] + array[1][3:], '%d.%m.%Y')
            day_to = datetime.strptime(array[1], '%d.%m.%Y')
            if day_from <= day <= day_to:
                day_iso = day.strftime("%Y-%m-%d")
                try:
                    self.driver.find_element_by_xpath(
                        "//a[@data-src[contains(.,'%s') and contains(.,'%s') and contains(.,'%s') and contains(.,'%s')]]"
                        % (param, self.employee_instance.get_id_employment(),
                           self.employee_instance.get_id(), day_iso))
                except NoSuchElementException:
                    assert False, "V docházkách se nepodařilo vytvořit záznam typu " + param
                else:
                    return
            if day > day_to:
                self.driver.find_element_by_xpath(
                    "//a[@class[contains(.,'right')]]").click()
                continue
            if day < day_from:
                self.driver.find_element_by_xpath(
                    "//a[@class[contains(.,'left')]]").click()
Exemplo n.º 19
0
class NewCompany4Page(BasePage):
    def __init__(self, driver):
        self.driver = driver
        self.link_add_organization_unit = self.driver.find_element(
            *NewCompany4PageLocators.link_add_organization_unit)
        self.button_continue = self.driver.find_element(
            *NewCompany4PageLocators.button_continue)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.field_name = self.driver.find_element(
            *NewCompany4PageLocators.field_name)
        self.field_new_cost_center_name = self.driver.find_element(
            *NewCompany4PageLocators.field_new_cost_center_name)
        self.field_new_cost_center_code = self.driver.find_element(
            *NewCompany4PageLocators.field_new_cost_center_code)
        self.radio_same_address_as_parent = self.driver.find_elements(
            *NewCompany4PageLocators.radio_same_address_as_parent)
        self.button_save = self.driver.find_element(
            *NewCompany4PageLocators.button_save)
        self.link_close = self.driver.find_element(
            *NewCompany4PageLocators.link_close)

    def click_link_add_organization_unit(self):
        time.sleep(0.5)
        self.link_add_organization_unit.click()
        self.waiter.wait_for_modal("open")

    def fill_field_name(self, name):
        self.field_name.clear()
        self.field_name.send_keys(name)
        self.field_name.send_keys(Keys.TAB)
        time.sleep(0.25)

    def fill_field_new_cost_center_name(self, new_cost_center_name):
        self.field_new_cost_center_name.clear()
        self.field_new_cost_center_name.send_keys(new_cost_center_name)

    def fill_field_new_cost_center_code(self, new_cost_center_code):
        self.field_new_cost_center_code.clear()
        self.field_new_cost_center_code.send_keys(new_cost_center_code)

    def select_radio_same_address_as_parent(self, same_address_as_parent):
        click_radio_by_value(self.radio_same_address_as_parent,
                             same_address_as_parent)

    def click_button_continue(self):
        self.button_continue.click()

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")

    def fill_form(self, company4):
        for item in company4:
            self.click_link_add_organization_unit()
            self()
            try:
                self.fill_field_name(item['name'])
                self.fill_field_new_cost_center_name(
                    item['new_cost_center_name'])
                self.fill_field_new_cost_center_code(
                    item['new_cost_center_code'])
                self.select_radio_same_address_as_parent(
                    item['same_address_as_parent'])
            except Exception as e:
                self.click_link_close()
                assert False, "Nepovedlo se přidat nové středisko: " + str(e)
            else:
                self.click_button_save()
            try:
                self.waiter.wait_for_modal("close")
            except TimeoutException:
                self()
                self.click_link_close()
                assert False, "Nepovedlo se přidat nové středisko!"
        self.click_button_continue()

    def test_basic_positive(self, company4):
        self.fill_form(company4)
        assert self.screens['company'][
            "5"] in self.driver.current_url, "Nepovedlo se odeslat 4. část formuláře pro vytvoření nové společnosti!"
class ChangeEmployment2BenefitsPage:

    reward_types = {
        "exact-amount": ChangeEmployment2PageLocators.field_exact_amount,
        "hourly-bonus": ChangeEmployment2PageLocators.field_hourly_amount,
        "percentual-bonus":
        ChangeEmployment2PageLocators.field_percentual_amount
    }

    locators = {
        "list_containts_benefit":
        "//*[@id='amendment-benefits-list']//td[@data-before[contains(.,'Typ odměny')]]",
        "link_to_delete":
        "(//*[@id='amendment-benefits-list']//*[@class='a-remove-benefit'])[1]"
    }

    def __init__(self, driver):
        self.driver = driver
        self.link_add_benefits = self.driver.find_element(
            *ChangeEmployment2PageLocators.link_add_benefits)
        self.button_save_and_continue = self.driver.find_element(
            *ChangeEmployment2PageLocators.button_save_and_continue)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.dropdown_type_id = self.driver.find_element(
            *ChangeEmployment2PageLocators.dropdown_type_id)
        self.button_save = self.driver.find_element(
            *ChangeEmployment2PageLocators.button_save)
        self.link_close = self.driver.find_element(
            *ChangeEmployment2PageLocators.link_close)

    def click_link_add_benefits(self):
        self.link_add_benefits.click()
        self.waiter.wait_for_modal("open")

    # BENEFITS
    def fill_dropdown_type_id(self, type_id):
        select_dropdown_item(self.dropdown_type_id, type_id)

    def fill_field_amount(self, reward_type, amount):
        if reward_type not in self.reward_types.keys():
            raise ValueError(
                "V testovacích datech je zadána neplatná hodnota parametru reward_type: "
                + reward_type)
        element = self.driver.find_element(*self.reward_types[reward_type])
        element.clear()
        element.send_keys(amount)

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")

    # -------------------------------------------------------------------------------------------------------------

    def click_button_save_and_continue(self):
        self.button_save_and_continue.click()

    def fill_form(self, change_employment2):
        try:
            count = len(
                self.driver.find_elements_by_xpath(
                    self.locators['list_containts_benefit']))
        except NoSuchElementException:
            pass
        else:
            while count > 0:
                count -= 1
                self.driver.find_element_by_xpath(
                    self.locators['link_to_delete']).click()
                self.waiter.wait_for_modal("open", param="remove_benefit")
                self.driver.find_element_by_xpath("//button").click()
                self.waiter.wait_for_modal("close", param="remove_benefit")
        for benefit in change_employment2['benefits']:
            self.add_benefit(benefit)
        self.click_button_save_and_continue()

    def test_basic_positive(self, change_employment2):
        self.fill_form(change_employment2)
        assert 'documents-and-evidence' in self.driver.current_url, "Nepodařilo se odeslat 2. část formuláře pro vytvoření dodatku!"

    def add_benefit(self, benefit):
        self.click_link_add_benefits()
        self()
        try:
            self.fill_dropdown_type_id(benefit['type_id'])
            self.fill_field_amount(benefit['reward_type'], benefit['amount'])
        except Exception as e:
            self.click_link_close()
            assert False, "Nepovedlo se přidat nový benefit: " + str(e)
        else:
            self.click_button_save()
        try:
            self.waiter.wait_for_modal("close")
        except TimeoutException:
            self()
            self.click_link_close()
            assert False, "Nepovedlo se přidat nový benefit!"
Exemplo n.º 21
0
 def __init__(self, driver):
     self.driver = driver
     self.button_show_search_form = self.driver.find_element(*SearchPageLocators.button_show_search_form)
     self.field_search = self.driver.find_element(*SearchPageLocators.field_search)
     self.button_search = self.driver.find_element(*SearchPageLocators.button_search)
     self.waiter = Waiter(self.driver, locator=SearchPageLocators.wrap)
Exemplo n.º 22
0
class NewCompany5Page(BasePage):
    roles = {
        "superior": "ROLE_SUPERIOR",
        "approver": "ROLE_APPROVER",
        "attendance_manager": "ROLE_ATTENDANCE_MANAGER"
    }

    def __init__(self, driver):
        self.driver = driver
        self.link_add_work_position = self.driver.find_element(
            *NewCompany5PageLocators.link_add_work_position)
        self.button_finish = self.driver.find_element(
            *NewCompany5PageLocators.button_finish)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.field_name = self.driver.find_element(
            *NewCompany5PageLocators.field_name)
        self.field_localized_names_for_contract_cs = self.driver.find_element(
            *NewCompany5PageLocators.field_localized_names_for_contract_cs)
        self.radio_for_all_organization_units = self.driver.find_elements(
            *NewCompany5PageLocators.radio_for_all_organization_units)
        self.radio_managing_position = self.driver.find_elements(
            *NewCompany5PageLocators.radio_managing_position)
        self.dropdown_medical_examination_work_category = self.driver.find_element(
            *
            NewCompany5PageLocators.dropdown_medical_examination_work_category)
        self.dropdown_job_group = self.driver.find_element(
            *NewCompany5PageLocators.dropdown_job_group)
        self.dropdown_shift_type = self.driver.find_element(
            *NewCompany5PageLocators.dropdown_shift_type)
        self.radio_working_hours_type = self.driver.find_elements(
            *NewCompany5PageLocators.radio_working_hours_type)
        self.dropdown_default_trial_period_months = self.driver.find_element(
            *NewCompany5PageLocators.dropdown_default_trial_period_months)
        self.dropdown_job_classification_id = self.driver.find_element(
            *NewCompany5PageLocators.dropdown_job_classification_id)
        self.checkbox_roles = self.driver.find_elements(
            *NewCompany5PageLocators.checkbox_roles)

        self.button_save = self.driver.find_element(
            *NewCompany5PageLocators.button_save)
        self.link_close = self.driver.find_element(
            *NewCompany5PageLocators.link_close)

    def click_link_add_work_position(self):
        time.sleep(0.5)
        self.link_add_work_position.click()
        self.waiter.wait_for_modal("open")

    def fill_field_name(self, name):
        self.field_name.clear()
        self.field_name.send_keys(name)

    def fill_field_localized_names_for_contract_cs(
            self, localized_names_for_contract_cs):
        self.field_localized_names_for_contract_cs.click()
        self.field_localized_names_for_contract_cs.clear()
        self.field_localized_names_for_contract_cs.send_keys(
            localized_names_for_contract_cs)

    def select_radio_for_all_organization_units(self, organization_units_ids):
        value = "1" if len(organization_units_ids) == 0 else "0"
        click_radio_by_value(self.radio_for_all_organization_units, value)

    def fill_dropdown_organization_units_ids(self, organization_units_ids):
        if len(organization_units_ids) > 0:
            element = self.driver.find_element(
                *NewCompany5PageLocators.dropdown_organization_units_ids)
            select_dropdown_item(element, organization_units_ids)

    def select_radio_managing_position(self, managing_position):
        click_radio_by_value(self.radio_managing_position, managing_position)

    def fill_dropdown_medical_examination_work_category(
            self, medical_examination_work_category):
        select_dropdown_item(self.dropdown_medical_examination_work_category,
                             medical_examination_work_category)

    def fill_dropdown_job_group(self, job_group):
        select_dropdown_item(self.dropdown_job_group, job_group)

    def fill_dropdown_shift_type(self, shift_type):
        select_dropdown_item(self.dropdown_shift_type, shift_type)

    def select_radioworking_hours_type(self, working_hours_type):
        click_radio_by_value(self.radio_working_hours_type, working_hours_type)

    def fill_dropdown_default_trial_period_months(self,
                                                  default_trial_period_months):
        select_dropdown_item(self.dropdown_default_trial_period_months,
                             default_trial_period_months)

    def fill_dropdown_job_classification_id(self, job_classification_id):
        select_dropdown_item(self.dropdown_job_classification_id,
                             job_classification_id, "known")

    def click_checkbox_role(self, roles):
        for role in roles:
            if role not in self.roles.values():
                raise ValueError("Nesprávná hodnota parametru roles")
        click_checkbox_by_value(self.checkbox_roles, roles)

    def fill_dropdown_superior_of_position_ids(self, superior_of_position_ids):
        element = self.driver.find_element(
            *NewCompany5PageLocators.dropdown_superior_of_position_ids)
        select_dropdown_item(element, superior_of_position_ids)

    def click_button_finish(self):
        self.button_finish.click()

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")

    def fill_form(self, company5):
        for item in company5:
            self.click_link_add_work_position()
            self()
            try:
                self.fill_field_name(item['name'])
                self.fill_field_localized_names_for_contract_cs(
                    item['localized_names_for_contract_cs'])
                self.select_radio_for_all_organization_units(
                    item['organization_units_ids'])
                self.fill_dropdown_organization_units_ids(
                    item['organization_units_ids'])
                self.select_radio_managing_position(item['managing_position'])
                self.fill_dropdown_medical_examination_work_category(
                    item['medical_examination_work_category'])
                self.fill_dropdown_job_group(item['job_group'])
                self.fill_dropdown_shift_type(item['shift_type'])
                self.select_radioworking_hours_type(item['working_hours_type'])
                self.fill_dropdown_default_trial_period_months(
                    item['default_trial_period_months'])
                self.fill_dropdown_job_classification_id(
                    item['job_classification_id'])
                self.click_checkbox_role(item['roles'])
                if "ROLE_SUPERIOR" in item['roles']:
                    self.fill_dropdown_superior_of_position_ids(
                        item['superior_of_position_ids'])
            except Exception as e:
                self.click_link_close()
                assert False, "Nepovedlo se přidat novou pozici: " + str(e)
            else:
                self.click_button_save()
            try:
                self.waiter.wait_for_modal("close")
            except TimeoutException:
                self()
                self.click_link_close()
                assert False, "Nepovedlo se přidat novou pozici!"
        self.click_button_finish()

    def test_basic_positive(self, company5):
        self.fill_form(company5)
        assert self.screens['company'][
            "finish"] in self.driver.current_url, "Nepovedlo se odeslat 5. část formuláře pro vytvoření nové společnosti!"
Exemplo n.º 23
0
class NewEmployment2Page:

    reward_types = {
        "exact-amount": NewEmployment2PageLocators.field_exact_amount,
        "hourly-bonus": NewEmployment2PageLocators.field_hourly_amount,
        "percentual-bonus": NewEmployment2PageLocators.field_percentual_amount
    }

    def __init__(self, driver):
        self.driver = driver
        self.dropdown_duration_months = self.driver.find_element(*NewEmployment2PageLocators.dropdown_duration_months)
        self.dropdown_trial_period_months = self.driver.find_element(*NewEmployment2PageLocators.dropdown_trial_period_months)
        self.dropdown_shift_type = self.driver.find_element(*NewEmployment2PageLocators.dropdown_shift_type)
        self.field_working_hours_per_week = self.driver.find_element(*NewEmployment2PageLocators.field_working_hours_per_week)
        self.radio_working_hours_type = self.driver.find_elements(*NewEmployment2PageLocators.radio_working_hours_type)
        self.link_add_benefits = None
        self.field_basic_salary = self.driver.find_element(*NewEmployment2PageLocators.field_basic_salary)
        self.button_save_and_continue = self.driver.find_element(*NewEmployment2PageLocators.button_save_and_continue)
        self.waiter = Waiter(self.driver)

    def __call__(self):
        self.dropdown_type_id = self.driver.find_element(*NewEmployment2PageLocators.dropdown_type_id)
        self.button_save = self.driver.find_element(*NewEmployment2PageLocators.button_save)
        self.link_close = self.driver.find_element(*NewEmployment2PageLocators.link_close)

    def fill_dropdown_duration_months(self, duration_months):
        select_dropdown_item(self.dropdown_duration_months, duration_months)

    def fill_dropdown_trial_period_months(self, trial_period_months):
        select_dropdown_item(self.dropdown_trial_period_months, trial_period_months)

    def fill_dropdown_shift_type(self, shift_type):
        select_dropdown_item(self.dropdown_shift_type, shift_type)

    def fill_field_working_hours_per_week(self, working_hours_per_week):
        self.field_working_hours_per_week.clear()
        self.field_working_hours_per_week.send_keys(working_hours_per_week)

    def select_radio_working_hours_type(self, working_hours_type):
        click_radio_by_value(self.radio_working_hours_type, working_hours_type)

    def fill_field_basic_salary(self, basic_salary):
        self.field_basic_salary.clear()
        self.field_basic_salary.send_keys(basic_salary)

    def click_link_add_benefits(self):
        self.link_add_benefits.click()
        self.waiter.wait_for_modal("open")

    # BENEFITS
    def fill_dropdown_type_id(self, type_id):
        select_dropdown_item(self.dropdown_type_id, type_id)

    def fill_field_amount(self, reward_type, amount):
        if reward_type not in self.reward_types.keys():
            raise ValueError("V testovacích datech je zadána neplatná hodnota parametru reward_type: " + reward_type)
        element = self.driver.find_element(*self.reward_types[reward_type])
        element.clear()
        element.send_keys(amount)

    def click_button_save(self):
        self.button_save.click()

    def click_link_close(self):
        self.link_close.click()
        self.waiter.wait_for_modal("close")
    # -------------------------------------------------------------------------------------------------------------

    def click_button_save_and_continue(self):
        self.button_save_and_continue.click()

    def fill_form(self, employment2):
        self.fill_dropdown_duration_months(employment2['duration_months'])
        self.fill_dropdown_trial_period_months(employment2['trial_period_months'])
        self.fill_dropdown_shift_type(employment2['shift_type'])
        self.fill_field_working_hours_per_week(employment2['working_hours_per_week'])
        self.select_radio_working_hours_type(employment2['working_hours_type'])
        self.fill_field_basic_salary(employment2['basic_salary'])
        if len(employment2['benefits']) > 0:
            self.link_add_benefits = self.driver.find_element(*NewEmployment2PageLocators.link_add_benefits)
            for benefit in employment2['benefits']:
                self.click_link_add_benefits()
                self()
                try:
                    self.fill_dropdown_type_id(benefit['type_id'])
                    self.fill_field_amount(benefit['reward_type'], benefit['amount'])
                except Exception as e:
                    self.click_link_close()
                    assert False, "Nepovedlo se přidat benefit: " + str(e)
                else:
                    self.click_button_save()
                try:
                    self.waiter.wait_for_modal("close")
                except TimeoutException:
                    self()
                    self.click_link_close()
                    assert False, "Nepovedlo se přidat benefit!"
        self.click_button_save_and_continue()

    def test_basic_positive(self, employment2):
        self.fill_form(employment2)
        assert 'other-agreements' in self.driver.current_url, "Nepovedlo se odeslat 2. část formuláře pro vytvoření poměru!"