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 type_header(self, header, index=None): if index is None: index = 1 self.open_more_options_menu(index) vals = header.values() keys = header.keys() length = len(vals) count = BasePage.count_elements(self, By.CSS_SELECTOR, self.row_number_prefix.format(index) + self.header_name_field) while count <= length: self.add_header_row(index) count += 1 i = 0 while i < len(vals): name = BasePage.find_element(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, i + 1) + self.header_name_field) value = BasePage.find_element(self, By.CSS_SELECTOR, self.row_header_prefix.format(index, i + 1) + self.header_value_field) BasePage.type(self, keys[i], name) BasePage.type(self, vals[i], value) i += 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 test_slot_present(self): assert BasePage.count_elements(self, By.CSS_SELECTOR, self.url_field) > 0, 'Failed to present url field'
def get_fields_count(self): return BasePage.count_elements(self, By.CSS_SELECTOR, self.url_field)