def add_header_row(self, index=None): if index is None: index = 1 self.open_more_options_menu(index) count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.header_name_field) BasePage.click(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.add_header_button) BasePage.wait_page(self) assert BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.header_name_field) == count + 1, 'Failed to add new row'
def delete_url_field(self, index=None): count = self.get_fields_count() if count > 0: elems = BasePage.find_elements(self, By.CSS_SELECTOR, self.delete_row_icon) # if no 'index' param - delete the last field if index is None: elems[len(elems) - 1].click() else: if index >= len(elems): raise NoSuchElementException( "You specify the field does not exist. Impossible to delete this Url field") else: elems[index - 1].click() BasePage.wait_page(self) assert self.get_fields_count() == count - 1
def delete_header_row(self, index=None, header_index=None): if index is None: index = 1 if header_index is None: header_index = 1 self.open_more_options_menu(index) count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.header_name_field) if count >= header_index and count is not 0: BasePage.click(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, header_index) + self.header_delete_row) BasePage.wait_page(self) else: raise NoSuchElementException('There is no such header') assert BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.header_name_field) == count - 1, 'Failed to delete header row'
def add_url_field(self): count = self.get_fields_count() BasePage.click(self, By.CSS_SELECTOR, self.add_row_button) BasePage.wait_page(self) assert self.get_fields_count() == count + 1
def click_more_options(self, index=None): if index is None: index = 1 BasePage.click(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.more_options_button) BasePage.wait_page(self)