def test_delete_spells(player_wizard, browser): # noqa """As a player, I can delete a spells.""" print('As a player, I can delete a spells.') spells_add = spells.SpellsAddModal(browser) spells_table = spells.SpellsTable(browser) tabs = Tabs(browser) tabs.spells.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, spells_table.add_id))) spells_table.add.click() ut.select_from_autocomplete(spells_add, 'name', browser, has_search_term=False) spells_add.description.click() spells_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) rows = ut.get_table_rows(spells_table, 'table', values=False) rows[0][7].find_element_by_tag_name('a').click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(spells_table)) rows = ut.get_table_rows(spells_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new spell'
def test_delete_feature(player_wizard, browser): # noqa """As a player, I can delete a feature.""" print('As a player, I can delete a feature.') feature = features.FeatureAddModal(browser) features_table = features.FeaturesTable(browser) tabs = Tabs(browser) tabs.skills.click() features_table.add.click() ut.select_from_autocomplete(feature, 'name', browser, has_search_term=False) feature.name.send_keys(Keys.TAB) feature.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(features_table)) rows = ut.get_table_rows(features_table, 'table', values=False) rows[0][2].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(features_table)) rows = ut.get_table_rows(features_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new Feature'
def test_delete_trait(player_wizard, browser): # noqa """As a player, I can delete a trait.""" print('As a player, I can delete a trait.') trait = traits.TraitAddModal(browser) traits_table = traits.TraitsTable(browser) tabs = Tabs(browser) tabs.skills.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, traits_table.add_id))) traits_table.add.click() ut.select_from_autocomplete(trait, 'name', browser, has_search_term=False) trait.name.send_keys(Keys.TAB) trait.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(traits_table)) rows = ut.get_table_rows(traits_table, 'table', values=False) rows[0][2].find_element_by_tag_name('a').click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(traits_table)) rows = ut.get_table_rows(traits_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new Trait'
def test_delete_proficiency(player_wizard, browser): # noqa """As a player, I can delete a proficiency.""" print('As a player, I can delete a proficiency.') proficiency_add = proficiency.ProficiencyAddModal(browser) proficiency_table = proficiency.ProficiencyTable(browser) tabs = Tabs(browser) tabs.skills.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, proficiency_table.add_id))) proficiency_table.add.click() ut.select_from_autocomplete(proficiency_add, 'name', browser, has_search_term=False) proficiency_add.name.send_keys(Keys.TAB) proficiency_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(proficiency_table)) rows = ut.get_table_rows(proficiency_table, 'table', values=False) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) rows[0][2].find_element_by_tag_name('a').click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(proficiency_table)) rows = ut.get_table_rows(proficiency_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new Proficiency'
def test_delete_armor(player_wizard, browser): # noqa """As a player, I can delete an armor.""" print('As a player, I can delete an armor.') armor_add = armor.ArmorAddModal(browser) armor_table = armor.ArmorTable(browser) tabs = Tabs(browser) tabs.equipment.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, armor_table.add_id))) armor_table.add.click() ut.select_from_autocomplete(armor_add, 'name', browser, has_search_term=False) armor_add.name.send_keys(Keys.TAB) armor_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(armor_table)) rows = ut.get_table_rows(armor_table, 'table', values=False) rows[0][4].find_element_by_tag_name('a').click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(armor_table)) rows = ut.get_table_rows(armor_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new armor'
def test_delete_inventory(player_wizard, browser): # noqa """As a player, I can delete an item in my inventory.""" print('As a player, I can delete an item to my inventory.') inventory_add = inventory.InventoryAddModal(browser) inventory_table = inventory.InventoryTable(browser) tabs = Tabs(browser) tabs.inventory.click() inventory_table.add.click() ut.select_from_autocomplete( inventory_add, 'name', browser, has_search_term=False ) inventory_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_has_data(inventory_table) ) rows = ut.get_table_rows(inventory_table, 'table', values=False) rows[0][5].find_element_by_tag_name('a').click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_is_empty(inventory_table) ) rows = ut.get_table_rows(inventory_table, 'table', values=False) assert rows[0][0].text.strip() == 'Add a new item'
def test_edit_read_aloud_text(dm_wizard, encounter_all_sections, browser): """As a dm, I can add, edit and delete a read aloud text in an encounter and the data persists.""" # noqa print( 'As a dm I can edit and delete a read aloud text in an encounter and the data persists ' ) # noqa read_aloud_text = ReadAloudTextAddModal(browser) read_aloud_table = ReadAloudTextTable(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, read_aloud_text.add_plus_icon_xpath))) read_aloud_text.add_plus_icon.click() stub = ReadAloudTextFactory.stub() read_aloud_text.name = stub.name read_aloud_text.description = stub.description read_aloud_text.add.click() read_aloud_edit = ReadAloudTextEditModal(browser) read_aloud_tabs = ReadAloudTextModalTabs(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, read_aloud_table.name_xpath))) time.sleep(1) read_aloud_table.name.click() edit = browser.find_elements_by_xpath(read_aloud_tabs.edit_xpath)[1] time.sleep(2) edit.click() edit.click() read_aloud_edit.name = stub.name read_aloud_edit.description = stub.description read_aloud_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, read_aloud_table.name_xpath))) before_refresh_name = read_aloud_table.name.text.strip() before_refresh_description = read_aloud_table.description.text.strip() browser.refresh() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, read_aloud_table.name_xpath))) after_refresh_name = read_aloud_table.name.text.strip() after_refresh_description = read_aloud_table.description.text.strip() assert before_refresh_name == after_refresh_name assert before_refresh_description == after_refresh_description read_aloud_text.remove.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(read_aloud_table)) assert read_aloud_text.add_new_point.text.strip( ) == 'Add new text for your players.'
def test_edit_map_or_image(dm_wizard, encounter_all_sections, browser): """As a dm, I can edit and delete a map or image to an encounter and the data persists.""" print( 'As a dm, I can edit and delete a map or image to an encounter and the data persists' ) # noqa map_or_image_modal = MapOrImageAddModal(browser) map_or_image_table = MapOrImageTable(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, map_or_image_modal.add_plus_icon_xpath))) map_or_image_modal.add_plus_icon.click() stub = MapOrImageFactory.stub() map_or_image_modal.name = stub.name map_or_image_modal.link = stub.image_link map_or_image_modal.description = stub.description map_or_image_modal.add.click() map_or_image_edit = MapOrImageEditModal(browser) map_or_image_tabs = MapOrImageModalTabs(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, map_or_image_table.name_xpath))) time.sleep(1) map_or_image_table.name.click() edit = browser.find_elements_by_xpath(map_or_image_tabs.edit_xpath)[1] time.sleep(1) edit.click() edit.click() map_or_image_edit.name = stub.name map_or_image_edit.link = stub.image_link map_or_image_edit.description = stub.description map_or_image_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, map_or_image_table.name_xpath))) before_refresh_name = map_or_image_table.name.text.strip() before_refresh_description = map_or_image_table.description.text.strip() browser.refresh() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, map_or_image_table.name_xpath))) after_refresh_name = map_or_image_table.name.text.strip() after_refresh_description = map_or_image_table.description.text.strip() assert before_refresh_name == after_refresh_name assert before_refresh_description == after_refresh_description map_or_image_modal.remove.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_is_empty(map_or_image_table)) assert map_or_image_modal.add_new_point.text.strip( ) == 'Add a new Map or Image.'
def test_edit_point_of_interest(dm_wizard, encounter_all_sections, browser): """As a dm, I can edit and delete a Point of interest to an encounter and the data persists.""" print( 'As a dm, I can edit and delete a Point of interest to an encounter and the data persists' ) # noqa point_of_interest_modal = PointOfInterestAddModal(browser) point_of_interest_table = PointOfInterestTable(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, point_of_interest_modal.add_plus_icon_xpath))) point_of_interest_modal.add_plus_icon.click() stub = PointOfInterestFactory.stub() point_of_interest_modal.name = stub.name point_of_interest_modal.description = stub.description point_of_interest_modal.add.click() point_of_interest_edit = PointOfInterestEditModal(browser) point_of_interest_tabs = PointOfInterestModalTabs(browser) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, point_of_interest_table.name_xpath))) time.sleep(1) point_of_interest_table.name.click() edit = browser.find_element_by_xpath(point_of_interest_tabs.edit_xpath) time.sleep(1) edit.click() point_of_interest_edit.name = stub.name point_of_interest_edit.description = stub.description point_of_interest_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, point_of_interest_table.name_xpath))) before_refresh_name = point_of_interest_table.name.text.strip() before_refresh_description = point_of_interest_table.description.text.strip( ) browser.refresh() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, point_of_interest_table.name_xpath))) after_refresh_name = point_of_interest_table.name.text.strip() after_refresh_description = point_of_interest_table.description.text.strip( ) assert before_refresh_name == after_refresh_name assert before_refresh_description == after_refresh_description point_of_interest_modal.remove.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_is_empty(point_of_interest_table)) assert point_of_interest_modal.add_new_point.text.strip( ) == 'Add a new Point of Interest'