def test_legal_objects_type_values(self, config): user = GkrUserSteps(config) queue_page = QueuePage(config) user.login(LEGAL.login, LEGAL.password) user.opens(Urls.QUEUE.url) user.should_see_list_values(queue_page.OBJECT_TYPE, ['---', '1', '2'])
def test_queue_operator_mobile_field(self, config, mobile, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.enters_text(queue_page.MOBILE, mobile) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.MOBILE_QUEUE.text)
def __init__(self, config): super().__init__(config) self.mysqlhost = config.mysqlhost self.login_form = LoginForm(config) self.main_menu = MainMenu(config) self.top_menu = TopMenu(config) self.reg_page = RegistrationPage(config) self.queue_page = QueuePage(config) self.news_page = NewsAdminPage(config)
def test_operator_queue_successful(self, config, teardown): operator = random_user(UserRoles.OPERATOR) user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) db_user.create_user(operator) global queue_operator_mobile queue_operator_mobile = operator.customers_data.mobile_phone day = (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d') print_day = (datetime.now() + timedelta(days=1)).strftime('%d.%m.%Y') locality = 'с. Александровка' street = 'ул. Виноградная' house = rand_num(2) flat = rand_num(2) user.login(operator.customers_data.mobile_phone, operator.password) user.should_see_element(queue_page) customer = user.fill_random_operator_queue() global queue_customer_by_operator_mobile queue_customer_by_operator_mobile = customer.mobile_phone user.chooses_from_select(queue_page.SERVICE, Services.DEAL_REGISTER.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.STROI_OBJECT.name) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.enters_text(queue_page.FLAT, flat) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) time = queue_page.CALENDAR.time_list[0].text user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.should_see_element_with_text(ticket_data_dialog.TICKET_TIME, (print_day + ' ' + time)) user.should_see_element_with_text(ticket_data_dialog.TICKET_SERVICE, Services.DEAL_REGISTER.name) user.should_see_element_with_text(ticket_data_dialog.TICKET_DEP, Departments.BEL_DEP.name) user.should_see_element_with_text( ticket_data_dialog.TICKET_CUSTOMER, customer.surname + " " + customer.name + " " + customer.patronymic) user.should_see_element_with_text( ticket_data_dialog.TICKET_ADDRESS, Departments.BEL_DEP.short_name + " " + locality + " " + street + " д. " + house + " кв. " + flat) db_user.should_see_service_group_id( ticket_data_dialog.TICKET_NUMBER.element.text, UserTypes.CUSTOMER.id)
def test_customer_objects_type_values(self, config): user = GkrUserSteps(config) queue_page = QueuePage(config) user.login(CUSTOMER.login, CUSTOMER.password) user.opens(Urls.QUEUE.url) object_types = list(map(str, ObjectTypes)) object_types.append('---') user.should_see_list_values(queue_page.OBJECT_TYPE, object_types)
def test_queue_operator_empty_locality_field(self, config, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.ADDRESS_MISMATCH.text)
def test_queue_operator_empty_house_field(self, config, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, 'с. Александровка') user.enters_suggest(queue_page.STREET, 'ул. Павлова') user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.ADDRESS_MISMATCH.text)
def test_custom_verify_button(self, config, setup): user = GkrUserSteps(config) queue_page = QueuePage(config) locality = randrus_str(10) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_text(queue_page.LOCALITY, locality) user.waits_for_element_displayed(queue_page.address_dialog) user.clicks(queue_page.address_dialog.VERIFY) user.waits_for_element_disappeared(queue_page.address_dialog) user.should_see_field_value(queue_page.OTHER, '') user.should_see_attribute_value(queue_page.OTHER, 'disabled', True)
def test_filling_data(self, config, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) report = '' attempts = config.attempts # тест прерывается, если указанное число раз подряд # не было свободного времени для записи city = Departments.BEL_DEP.short_name locality = 'а' street = 'ул. Виноградная' i = 0 while i < int(attempts): service = random.choice(list(services.Services)).name object_type = random.choice(list(object_types.ObjectTypes)).name user.waits_for_element_displayed(queue_page) user.fill_random_operator_queue() user.chooses_from_select(queue_page.SERVICE, service) user.chooses_from_select(queue_page.OBJECT_TYPE, object_type) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, 1) user.set_calendar_date(queue_page.CALENDAR, config.timeslot_date) if user.set_calendar_time(queue_page.CALENDAR, None) != 0: user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) if 'занято' not in config.driver.find_element(By.TAG_NAME, 'body').text: user.should_see_element(ticket_data_dialog) row = u'\nНомер тикета : ' + ticket_data_dialog.TICKET_NUMBER.element.text \ + u'\nДата записи : ' + ticket_data_dialog.TICKET_TIME.element.text \ + u'\nУслуга : ' + service \ + u'\nТип объекта недвижимости : ' + object_type \ + u'\nГород : ' + city \ + u'\n===' i = 0 else: row = u'Время ' + config.timeslot_date + ' занято.' else: row = u'\nДата записи : ' + config.timeslot_date \ + u'\nДля услуги \'' + service + '\' и объекта \'' + object_type \ + '\' свободное время записи закончилось.' i += 1 report += row user.reloads_page() allure.attach('response.log', str(report), type=AttachmentType.TEXT)
def test_queue_operator_fio_field(self, config, fio, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.enters_text(queue_page.SURNAME, fio) user.enters_text(queue_page.NAME, fio) user.enters_text(queue_page.PATRONYMIC, fio) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.NAME_EMPTY.text, ErrorMessages.NAME_LENGTH.text) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.SURNAME_EMPTY.text, ErrorMessages.SURNAME_LENGTH.text)
def test_queue_operator_passport_serial_field(self, config, passport, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.enters_text(queue_page.PASSPORT_SERIAL, passport) user.enters_text(queue_page.PASSPORT_NUMBER, passport) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.PASSPORT_SERIAL.text, ErrorMessages.PASSPORT_SERIAL_ONLY_DIGITS.text) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.PASSPORT_NUMBER.text, ErrorMessages.PASSPORT_NUMBER_ONLY_DIGITS.text)
def test_custom_street(self, config, setup): user = GkrUserSteps(config) queue_page = QueuePage(config) locality = 'с. Александровка' street = randrus_str(10) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_text(queue_page.STREET, street) user.waits_for_element_displayed(queue_page.address_dialog) user.clicks(queue_page.address_dialog.MANUAL) user.waits_for_element_disappeared(queue_page.address_dialog) user.should_see_element_enabled(queue_page.OTHER) user.should_see_field_value(queue_page.OTHER, locality + ', ' + street)
def setup(request): global fields_operator config = getattr(request, '_funcargs')['config'] db_user = GkrDbSteps(config) queue_page = QueuePage(config) fields_operator = random_user(UserRoles.OPERATOR) db_user.create_user(fields_operator) user = GkrUserSteps(config) user.login(fields_operator.customers_data.mobile_phone, fields_operator.password) user.waits_for_element_displayed(queue_page)
def test_legal_timeslot(self, config): user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) profile_page = ProfilePage(config) ticket_data_dialog = TicketDataDialog(config) for i in legal_timeslot_data: legal = random_user(UserRoles.CUSTOMER, is_legal=True) db_user.create_user(legal) day = (datetime.now() + timedelta(days=random.randrange(0, 2))).strftime('%Y-%m-%d') service = i[0] stat_value = i[1] locality = 'с. Виноградное' street = 'ул. Горная' user.login(legal.customers_data.mobile_phone, legal.password) user.waits_for_element_displayed(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.chooses_from_select(queue_page.SERVICE, service) user.chooses_from_select(queue_page.OBJECT_TYPE, '1') user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, 2) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) user.enters_text(queue_page.CAPTCHA, '11111') user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.login(legal.customers_data.mobile_phone, legal.password) user.waits_for_element_displayed(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.chooses_from_select(queue_page.SERVICE, service) user.waits_for_ajax() user.should_see_element_with_text(queue_page.STAT_INDICATOR, stat_value) db_user.delete_user_by_mobile(legal.customers_data.mobile_phone)
def test_queue_no_time_operator(self, config, setup): operator = OPERATOR user = GkrUserSteps(config) queue_page = QueuePage(config) user.login(operator.customers_data.mobile_phone, operator.password) user.should_see_element(queue_page) user.chooses_from_select(queue_page.SERVICE, Services.SINGLE_WINDOW.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.DOMOVLADENIE.name) user.chooses_from_select(queue_page.CITY, Departments.SIMF_DEP.short_name) user.waits_for_element_displayed(queue_page.QUEUE_FULL_MESSAGE) user.should_see_element_with_text( queue_page.QUEUE_FULL_MESSAGE, ErrorMessages.NEXT_OPENING_DATE.text + next_opening_date.strftime('%d.%m.%Y'))
def test_queue_no_time_customer(self, config, setup): customer = CUSTOMER user = GkrUserSteps(config) main_page = MainPage(config) queue_page = QueuePage(config) user.login(customer.customers_data.mobile_phone, customer.password) user.waits_for_element_displayed(main_page.top_menu.LOGOUT) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.chooses_from_select(queue_page.SERVICE, Services.GKN.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.STROI_OBJECT.name) user.chooses_from_select(queue_page.CITY, Departments.SIMF_DEP.short_name) user.waits_for_element_displayed(queue_page.QUEUE_FULL_MESSAGE) user.should_see_element_with_text( queue_page.QUEUE_FULL_MESSAGE, ErrorMessages.NEXT_OPENING_DATE.text + next_opening_date.strftime('%d.%m.%Y'))
def fill_random_operator_queue(self): queue_page = QueuePage(self.config) customer = Customers customer.name = randrus_str(10) customer.surname = randrus_str(10) customer.patronymic = randrus_str(10) customer.mobile_phone = '9777' + rand_num(6) customer.email = rand_num(6) + '@' + rand_str(5) + '.com' customer.no = rand_num(6) customer.serial = rand_num(4) customer.issue = randrus_str(25) customer.when_at = '09/01/2015' self.enters_text(queue_page.SURNAME, customer.surname) self.enters_text(queue_page.NAME, customer.name) self.enters_text(queue_page.PATRONYMIC, customer.patronymic) self.enters_text(queue_page.MOBILE, customer.mobile_phone) self.enters_text(queue_page.PASSPORT_SERIAL, customer.serial) self.enters_text(queue_page.PASSPORT_NUMBER, customer.no) self.enters_text(queue_page.ISSUE, customer.issue) self.enters_text(queue_page.ISSUE_DATE, customer.when_at) return customer
def test_queue_operator_empty_fields(self, config, setup, teardown): user = GkrUserSteps(config) queue_page = QueuePage(config) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.ERROR_TEXT) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.ADDRESS_MISMATCH.text) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.DATE_NOT_SPECIFIED.text) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.PASSPORT_NUMBER_ONLY_DIGITS.text, ErrorMessages.PASSPORT_NUMBER.text) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.PASSPORT_SERIAL.text, ErrorMessages.PASSPORT_SERIAL_ONLY_DIGITS.text) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.NAME_EMPTY.text, ErrorMessages.NAME_LENGTH.text) user.should_see_text_in_list(queue_page.ERROR_TEXT, ErrorMessages.SURNAME_EMPTY.text, ErrorMessages.SURNAME_LENGTH.text)
def test_operator_timeslot(self, config): user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) day = (datetime.now() + timedelta(days=random.randrange(0, 2))).strftime('%Y-%m-%d') locality = 'с. Виноградное' street = 'ул. Горная' house = 1 for i in operator_timeslot_data: operator = random_user(UserRoles.OPERATOR) db_user.create_user(operator) object_type = i[0] stat_value = i[1] user.login(operator.customers_data.mobile_phone, operator.password) user.should_see_element(queue_page) user.fill_random_operator_queue() user.chooses_from_select(queue_page.SERVICE, Services.DEAL_REGISTER.name) user.chooses_from_select(queue_page.OBJECT_TYPE, object_type) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.opens(Urls.REGISTRATOR) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.waits_for_ajax() user.should_see_element_with_text(queue_page.STAT_INDICATOR, stat_value) db_user.delete_user_by_mobile(operator.customers_data.mobile_phone)
def test_customer_queue_successful(self, config, teardown): customer = random_user(UserRoles.CUSTOMER) user = GkrUserSteps(config) db_user = GkrDbSteps(config) profile_page = ProfilePage(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) db_user.create_user(customer) global queue_mobile queue_mobile = customer.customers_data.mobile_phone day = (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d') print_day = (datetime.now() + timedelta(days=1)).strftime('%d.%m.%Y') locality = 'с. Александровка' street = 'ул. Виноградная' house = rand_num(2) + '/1a' flat = rand_num(2) + 'б' user.login(customer.customers_data.mobile_phone, customer.password) user.should_see_element(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.chooses_from_select(queue_page.SERVICE, Services.SINGLE_WINDOW.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.DOMOVLADENIE.name) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.enters_text(queue_page.FLAT, flat) user.enters_text(queue_page.CAPTCHA, '11111') user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.CALENDAR) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) time = queue_page.CALENDAR.time_list[0].text user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) ticket_id = ticket_data_dialog.TICKET_NUMBER.element.text user.should_see_element_with_text(ticket_data_dialog.TICKET_TIME, (print_day + ' ' + time)) user.should_see_element_with_text(ticket_data_dialog.TICKET_SERVICE, Services.SINGLE_WINDOW.name) user.should_see_element_with_text(ticket_data_dialog.TICKET_DEP, Departments.BEL_DEP.name) user.should_see_element_with_text( ticket_data_dialog.TICKET_CUSTOMER, customer.customers_data.surname + " " + customer.customers_data.name + " " + customer.customers_data.patronymic) user.should_see_element_with_text( ticket_data_dialog.TICKET_ADDRESS, Departments.BEL_DEP.short_name + " " + locality + " " + street + " д. " + house + " кв. " + flat) db_user.should_see_service_group_id(ticket_id, UserTypes.CUSTOMER.id) user.close(ticket_data_dialog) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed = user.waits_for_element_displayed( queue_page.ERROR_TEXT) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.CUSTOMER_REGISTRATION_LIMIT.text % (customer.customers_data.serial, customer.customers_data.no, ticket_id)) user.opens(Urls.PROFILE) history_item = profile_page.TICKETS_HISTORY.get_history_by_id( ticket_id) user.should_see_history_services(history_item, ticket_id, Services.SINGLE_WINDOW.name, print_day + ' ' + time)