Example #1
0
 def get_rating_value_from_hotel_list(self, saved_values):
     self.click(*RegisterHotelLocators.go_to_end_button)
     hotel_name = saved_values.get('Name')
     BaseLogger.get_info_log(f'Get saved hotel rating for hotel with name {hotel_name}')
     xref = list(RegisterHotelLocators.rating_value_hotel_list)
     xref[1] = xref[1].format(hotel_name)
     locator = tuple(xref)
     return self.get_value_from_grid_or_dropdown(*locator)
Example #2
0
 def select_value_from_dropdown(self, field, **kwargs):
     xref = list(dropdown_value.get(field))
     value = kwargs.get('value', DEFAULT_VALUES.get(field))
     xref[1] = xref[1].format(value)
     dropdown_value_locator = tuple(xref)
     dropdown_locator = input_fields.get(field)
     BaseLogger.get_info_log(f'Select value {value} from dropdown {field}')
     self.open_dropdown_and_click_on_value(dropdown_locator, dropdown_value_locator)
     return self.get_value_from_grid_or_dropdown(*dropdown_locator)
Example #3
0
 def fill_registration_hotel_form_by_data(self, **kwargs):
     BaseLogger.get_info_log('Fill registration form by data')
     generated_hotel_values = kwargs.get('random_values', DEFAULT_VALUES)
     for field in mandatory_fields:
         if field in editable_dropdown_fields:
             self.select_value_from_dropdown(field)
         else:
             self.type_text_to_field(generated_hotel_values.get(field), field)
     return generated_hotel_values
Example #4
0
 def post(self, url, body):
     BaseLogger.get_info_log('Sending POST url: {} body: {}.'.format(
         url, body))
     response = requests.post(url, data=body)
     parsed_response = self.parse_response_to_json(response)
     BaseLogger.get_info_log('Received "{}".'.format(response))
     BaseLogger.get_info_log('Response body "{}".'.format(parsed_response))
     return response
Example #5
0
 def check_error_message_is_present(self, field):
     BaseLogger.get_info_log(f'Check error message is present for field {field}')
     locator = error_messages.get(field)
     return self.is_displayed(*locator)
Example #6
0
 def type_text_to_field(self, text, field):
     BaseLogger.get_info_log(f'Type {text} to field {field}')
     locator = input_fields.get(field)
     self.type(text, *locator)
     return self.get_field_input_value(*locator)
Example #7
0
 def check_field_marked_as_asterisk(self, field):
     BaseLogger.get_info_log(f'Check {field} field is marked with asterisk')
     locator = asterisk_fields.get(field)
     return self.is_displayed(*locator)
Example #8
0
 def check_dropdown_is_editable(self, field):
     BaseLogger.get_info_log(f'Check {field} field is editable')
     test_value = DEFAULT_VALUES.get(field)
     selected_value = self.select_value_from_dropdown(field, value=test_value)
     return selected_value == test_value
Example #9
0
 def get_users_list(self, page):
     BaseLogger.get_info_log(f'Get user from page {page}')
     url = f'{self.root_url}{self.users_path}?page={page}'
     response = self.get(url)
     return response
Example #10
0
 def check_actual_value_in_hotels_grid(self, value):
     BaseLogger.get_info_log(f'Check {value} is present in hotels grid')
     xref = list(RegisterHotelLocators.hotel_value)
     xref[1] = xref[1].format(value)
     locator = tuple(xref)
     return self.is_displayed(*locator)
Example #11
0
 def click_on_save_button(self):
     BaseLogger.get_info_log('Click on save button')
     self.click(*TopMenuBarLocators.save_button)
Example #12
0
 def check_save_button_is_present(self):
     BaseLogger.get_info_log('Check save button is present')
     return self.is_displayed(*TopMenuBarLocators.save_button)
Example #13
0
 def check_data_section_is_present(self):
     BaseLogger.get_info_log('Check data section is present')
     return self.is_displayed(*TopMenuBarLocators.data_section)
Example #14
0
 def go_to_register_hotel_page(self):
     BaseLogger.get_info_log('Go to register hotel page')
     self.open_page(self.common_config.get('ui_pages', 'register_new_hotel'))
Example #15
0
 def get(url):
     BaseLogger.get_info_log('Sending GET url: {}.'.format(url))
     response = requests.get(url)
     return response
Example #16
0
 def check_field_is_displayed(self, field):
     BaseLogger.get_info_log(f'Check {field} field is displayed')
     locator = displayed_fields.get(field)
     return self.is_displayed(*locator)
Example #17
0
 def check_hotel_was_created(self, saved_data):
     BaseLogger.get_info_log('Check hotel was created')
     self.click(*RegisterHotelLocators.go_to_end_button)
     for k, v in saved_data.items():
         if k not in editable_date_fields and k in hotel_list_fields:
             assert self.check_actual_value_in_hotels_grid(v)
Example #18
0
 def check_input_field_is_editable(self, field, date_format=False):
     BaseLogger.get_info_log(f'Check {field} field is editable')
     locator = input_fields.get(field)
     return self.is_editable(*locator, date_format=date_format)
Example #19
0
 def select_rating(self, rating):
     BaseLogger.get_info_log(f'Select hotel rating: {rating}')
     xref = list(RegisterHotelLocators.rating_star)
     xref[1] = xref[1].format(rating)
     rating_star_locator = tuple(xref)
     self.click(*rating_star_locator)
Example #20
0
 def create_user(self, user_data):
     BaseLogger.get_info_log('Creating user...')
     url = f'{self.root_url}{self.users_path}'
     response = self.post(url, user_data)
     return response