def check_error_message(self): """return the error message assertion status""" next_button = self.browser.find_element(*self.next_button) custom_click(self.browser, next_button) end_date = self.browser.find_element(*self.end_date_input) move_to_element(self.browser, end_date) return find_element(self.browser, self.mandatory_error_message)
def check_error_message(self, input_data): """return the error message assertion status""" next_button = self.browser.find_element(*self.next_button) custom_click(self.browser, next_button) assertion = find_element(self.browser, self.mandatory_error_message) self.browser.find_element(*self.name).send_keys(input_data['Name']) custom_click(self.browser, next_button) return assertion
def is_logged_in(self, email): """check if user is already logged in""" wait_for_element(self.browser, self.expand_left_panel) expand_panel = self.browser.find_element(*self.expand_left_panel) custom_click(self.browser, expand_panel) wait_for(lambda: len(self.browser.find_element(*self.logged_user).text) > 0, delay=1, num_sec=5) user_logged_in = self.browser.find_element(*self.logged_user).text if user_logged_in == email: return True else: raise Exception('Failed to login by user => {}'.format(email))
def fill_the_end_date(self, input_data): """fill the end date on rewards mechanics page """ end_date = self.browser.find_element(*self.end_date_input) move_to_element(self.browser, end_date) end_date.click() today = datetime.date.today() tomorrow = today + datetime.timedelta(days=1) next_date = "{} {}, {}".format(tomorrow.strftime("%B"), tomorrow.day, tomorrow.year) next_date_locator = (By.XPATH, "//td[@title='{}']".format(next_date)) element = self.browser.find_element(*next_date_locator) custom_click(self.browser, element)
def check_sections_after_disable_on_ui(self): """check that sections are disable correctly and return the result""" self.navigate_to_reward_create_page() elements = self.browser.find_elements(*self.switcher_button) for element in elements: move_to_element(self.browser, element) custom_click(self.browser, element) for locator in (self.upload_file_button, self.create_merchant, self.add_selling_price): if find_element(self.browser, locator): return False else: return True
def fill(self, input_data): """fill the form on the rewards info page""" if 'Type' in input_data: if input_data['Type'].lower() in ('public', 'private', 'system'): reward_type = self.select_reward_type(input_data['Type']) self.browser.find_element(*reward_type).click() else: raise Exception("Not a valid reward type ! ") for attribute, locator in [('Name', self.name), ('Subtitle', self.subtitle), ('Description', self.description)]: self._self_fill_inputs(attribute, input_data, locator) for attribute, locator in [('Brands', self.brands), ('Tags', self.tags), ('Catalogues', self.catalogues)]: self._self_fill_tags(attribute, input_data, locator) next_button = self.browser.find_element(*self.next_button) custom_click(self.browser, next_button)
def upload_file(self, file_path, action_dict=None): """upload file in upload widget""" bulk_action_panel = self.browser.find_element(*self.bulk_actions) bulk_action_panel.click() self.open_upload_model() if action_dict is not None: self._select_action(action_dict) upload_input = self.browser.find_element(*self.upload_input) self.browser.execute_script("arguments[0].style.display = 'block';", upload_input) upload_input.send_keys(file_path) file_name = get_file_name(file_path) upload_results = self.browser.find_element( *self.upload_results(file_name)) upload_button_in_modal = self.browser.find_element( *self.upload_button_in_modal) if upload_results.text == file_name: print("File Present In Model") custom_click(self.browser, upload_button_in_modal) ensure_no_error_message(self.browser, self.error_message)
def log_out(self): """logout from system""" self.logout = (By.XPATH, "//span[text()='Logout']") logout_link = self.browser.find_element(*self.logout) custom_click(self.browser, logout_link)
def fill(self, input_data): """fill the form on the rewards mechanics page""" self.fill_the_end_date(input_data) next_button = self.browser.find_element(*self.next_button) custom_click(self.browser, next_button)
def launch_reward(self): """click on launch reward button""" launch_button = self.browser.find_element(*self.launch_button) custom_click(self.browser, launch_button)
def open_upload_model(self): """open the upload widget""" wait_for_element(self.browser, self.upload_button) upload_button = self.browser.find_element(*self.upload_button) custom_click(self.browser, upload_button)