def test_armor_persists(player_wizard, browser): # noqa """As a player, all fields for armor persist after page refresh.""" print('As a player, all fields for armor persist after page refresh.') armor_add = armor.ArmorAddModal(browser) armor_edit = armor.ArmorEditModal(browser) armor_table = armor.ArmorTable(browser) armor_tabs = armor.ArmorModalTabs(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() browser.refresh() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(armor_table)) row = ut.get_table_row(armor_table, 'table', 1) assert row.armor.strip() == 'Breastplate' assert row.armor_class.strip() == '14' assert row.type.strip() == 'Medium' row = ut.get_table_row(armor_table, 'table', values=False) row[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, armor_tabs.edit_id))) armor_tabs.edit.click() # Sometimes the done button is greyed out, and we need to click twice for some reason armor_tabs.edit.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, armor_edit.name_id))) assert armor_edit.name.get_attribute('value').strip() == 'Breastplate' assert armor_edit.armor_class.get_attribute('value').strip() == '14' assert armor_edit.type_.get_attribute('value').strip() == 'Medium' assert armor_edit.magical_modifier.get_attribute('value').strip() == '0' assert armor_edit.price.get_attribute('value').strip() == '400' assert armor_edit.currency_denomination.get_attribute( 'value').strip() == 'GP' assert armor_edit.weight.get_attribute('value').strip() == '20' assert armor_edit.armor_class.get_attribute('value').strip() == '14' assert armor_edit.stealth.get_attribute('value').strip() == 'Normal' assert 'armor consists of' in armor_edit.description.get_attribute( 'value').strip()
def test_charisma_increase(player_wizard, browser): # noqa """When charisma is increased or decreased, relevant skills and savings throws reflect the change.""" print(('When charisma is increased or decreased, relevant skills and ' 'savings throws reflect the change.')) saving_throw = SavingThrowTable(browser) skills = SkillsTable(browser) ability_scores_table = AbilityScoresTable(browser) ability_scores_edit = AbilityScoresEditModal(browser) tabs = Tabs(browser) ability_scores_table.table.click() ability_scores_edit.charisma = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 1)) charisma = ut.get_table_row(saving_throw, 'table', row_number=1) tabs.skills.click() deception = ut.get_table_row(skills, 'table', row_number=5) intimidation = ut.get_table_row(skills, 'table', row_number=8) performance = ut.get_table_row(skills, 'table', row_number=13) persuasion = ut.get_table_row(skills, 'table', row_number=14) assert charisma.blank2.strip() == '+ 2' assert deception.blank2.strip() == '+ 2 (Cha)' assert intimidation.blank2.strip() == '+ 2 (Cha)' assert performance.blank2.strip() == '+ 2 (Cha)' assert persuasion.blank2.strip() == '+ 2 (Cha)'
def test_saving_throw_modifier(player_wizard, browser): # noqa """As a player, I can increase or decrease my savings throws via a modifier field""" print(('As a player, I can increase or decrease my savings throws via a ' 'modifier field.')) time.sleep(10) saving_throw = SavingThrowTable(browser) saving_throw_edit = SavingThrowEditModal(browser) row = ut.get_table_row(saving_throw, 'table', values=False) # open edit modal row[0].click() saving_throw_edit.modifier = 1 saving_throw_edit.modifier.send_keys(Keys.TAB) saving_throw_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 5', 'table', 1)) row = ut.get_table_row(saving_throw, 'table') assert row.blank2.strip() == '+ 5'
def test_saving_throw_proficiency(player_wizard, browser): # noqa """As a player, I can select to become proficient in a savings throw, and this can be viewed in the table via in icon.""" print( ('As a player, I can select to become proficient in a savings throw, ' 'and this can be viewed in the table via in icon.')) saving_throw = SavingThrowTable(browser) saving_throw_edit = SavingThrowEditModal(browser) time.sleep(10) row = ut.get_table_row(saving_throw, 'table', values=False) # open edit modal row[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, saving_throw_edit.proficiency.get_attribute('id')))) saving_throw_edit.proficiency.click() saving_throw_edit.modifier.click() saving_throw_edit.done.click() # add custom wait to test for class in nested element WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) row = ut.get_table_row(saving_throw, 'table', values=False) span = row[0].find_elements(By.TAG_NAME, 'span') assert span[0].get_attribute('class').strip() == 'fa fa-check'
def test_proficiency_types(player_wizard, browser): # noqa """As a player, I can mark a skill as none, half, proficient, or expertise and view these modifiers, and they are calculated correctly.""" print(('As a player, I can mark a skill as none, half, proficient, or ' 'expertise and view these modifiers, and they are calculated ' 'correctly.')) skills_table = skills.SkillsTable(browser) skills_edit = skills.SkillsEditModal(browser) tabs = Tabs(browser) tabs.skills.click() acrobatics = ut.get_table_row(skills_table, 'table', values=False) none = acrobatics[0].find_element_by_tag_name('span').get_attribute( 'class') acrobatics[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, skills_edit.half_xpath))) skills_edit.half.click() skills_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) time.sleep(.4) acrobatics = ut.get_table_row(skills_table, 'table', values=False) spans = acrobatics[0].find_element_by_tag_name('span') half = spans.find_element_by_tag_name('span').get_attribute('class') acrobatics[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, skills_edit.proficient_xpath))) skills_edit.proficient.click() skills_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) time.sleep(.4) acrobatics = ut.get_table_row(skills_table, 'table', values=False) spans = acrobatics[0].find_element_by_tag_name('span') proficient = spans.find_element_by_tag_name('span').get_attribute('class') acrobatics[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.XPATH, skills_edit.expertise_xpath))) skills_edit.expertise.click() skills_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) time.sleep(.4) acrobatics = ut.get_table_row(skills_table, 'table', values=False) spans = acrobatics[0].find_element_by_tag_name('span') expertise = spans.find_element_by_tag_name('span').get_attribute('class') assert '' in none.strip() assert 'fa fa-adjust' in half.strip() assert 'fa fa-check' in proficient.strip() assert 'fa fa-check close-check' in expertise.strip()
def test_inventory_persists(player_wizard, browser): # noqa """As a player, all fields for inventory persist after page refresh.""" print('As a player, all fields for inventory persist after page refresh.') inventory_add = inventory.InventoryAddModal(browser) inventory_edit = inventory.InventoryEditModal(browser) inventory_table = inventory.InventoryTable(browser) inventory_tabs = inventory.InventoryModalTabs(browser) tabs = Tabs(browser) tabs.inventory.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, inventory_table.add_id) ) ) inventory_table.add.click() ut.select_from_autocomplete( inventory_add, 'name', browser, has_search_term=False ) inventory_add.add.click() browser.refresh() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_has_data(inventory_table) ) row = ut.get_table_row(inventory_table, 'table', 1) assert row.item.strip() == 'Abacus' assert row.weight.strip() == '2 lbs.' assert row.quantity.strip() == '1' assert row.cost.strip() == '2 GP' assert row.description.strip() == '' row = ut.get_table_row(inventory_table, 'table', values=False) row[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, inventory_tabs.edit_id) ) ) inventory_tabs.edit.click() assert inventory_edit.name.get_attribute('value').strip() == 'Abacus' assert inventory_edit.weight.get_attribute('value').strip() == '2' assert inventory_edit.quantity.get_attribute('value').strip() == '1' assert inventory_edit.cost.get_attribute('value').strip() == '2' assert inventory_edit.currency_denomination.get_attribute('value').strip() == 'GP' assert inventory_edit.description.get_attribute('value').strip() == ''
def test_inventory_sorting(player_wizard, browser): # noqa """As a player, I can sort the inventory table by clicking on the sortable columns.""" print(('As a player, I can sort the inventory table by clicking on the ' 'sortable columns')) inventory_add = inventory.InventoryAddModal(browser) inventory_table = inventory.InventoryTable(browser) tabs = Tabs(browser) tabs.inventory.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, inventory_table.add_id))) 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()) inventory_table.add.click() ut.select_from_autocomplete(inventory_add, 'name', browser, arrow_down_count=2) inventory_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) inventory_table.item_header.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( sorting_arrow_down(inventory_table.item_header_sorting_arrow, )) rows = ut.get_table_row(inventory_table, 'table', values=False) assert rows[0].text.strip() == 'Acid (vial)' inventory_table.quantity_header.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( sorting_arrow_up(inventory_table.quantity_header_sorting_arrow, )) rows = ut.get_table_row(inventory_table, 'table', values=False) assert rows[1].text.strip() == '1' inventory_table.weight_header.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( sorting_arrow_up(inventory_table.weight_header_sorting_arrow, )) rows = ut.get_table_row(inventory_table, 'table', values=False) assert rows[2].text.strip() == '1 lbs.'
def test_dexterity_increase(player_wizard, browser): # noqa """When dexterity is increased or decreased, relevant skills, savings throws, initiative, and to hit (finesse weapons) reflect the change.""" print(('When dexterity is increased or decreased, relevant skills, ' 'savings throws, initiative, and to hit (finesse weapons) reflect ' 'the change.')) saving_throw = SavingThrowTable(browser) skills = SkillsTable(browser) ability_scores_table = AbilityScoresTable(browser) ability_scores_edit = AbilityScoresEditModal(browser) weapon_table = WeaponTable(browser) weapon_add = WeaponAddModal(browser) stats = OtherStats(browser) tabs = Tabs(browser) ability_scores_table.table.click() # str needs to be less than dex as we are testing finesse weapon # i.e. the higher of str and dex is used ability_scores_edit.strength = 10 ability_scores_edit.dexterity = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 3)) dexterity = ut.get_table_row(saving_throw, 'table', row_number=3) initiative = stats.initiative.text tabs.skills.click() acrobatics = ut.get_table_row(skills, 'table', row_number=1) sleight_of_hand = ut.get_table_row(skills, 'table', row_number=16) stealth = ut.get_table_row(skills, 'table', row_number=17) tabs.equipment.click() weapon_table.add.click() # select a dagger ut.select_from_autocomplete(weapon_add, 'name', browser, has_search_term=False, arrow_down_count=7) weapon_add.add.click() to_hit = ut.get_table_row(weapon_table, 'table').to_hit assert dexterity.blank2.strip() == '+ 2' assert initiative.strip() == '2' assert to_hit.strip() == '+ 4' assert acrobatics.blank2.strip() == '+ 2 (Dex)' assert sleight_of_hand.blank2.strip() == '+ 2 (Dex)' assert stealth.blank2.strip() == '+ 2 (Dex)'
def test_magic_items_persists(player_wizard, browser): # noqa """As a player, all fields for magic_items persist after page refresh.""" print( 'As a player, all fields for magic_items persist after page refresh.') magic_items_add = magic_items.MagicItemsAddModal(browser) magic_items_edit = magic_items.MagicItemsEditModal(browser) magic_items_table = magic_items.MagicItemsTable(browser) magic_items_tabs = magic_items.MagicItemsModalTabs(browser) tabs = Tabs(browser) tabs.inventory.click() magic_items_table.add.click() ut.select_from_autocomplete(magic_items_add, 'item', browser, has_search_term=False) magic_items_add.add.click() browser.refresh() row = ut.get_table_row(magic_items_table, 'table', 1) assert row.magic_item.strip() == 'Adamantine Armor' assert row.charges.strip() == 'N/A' assert row.weight.strip() == '0 lbs.' assert 'with adamantine' in row.description.strip() row = ut.get_table_row(magic_items_table, 'table', 1, values=False) assert row[2].find_element_by_tag_name('input').is_displayed() is False row = ut.get_table_row(magic_items_table, 'table', values=False) row[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, magic_items_tabs.edit_id))) magic_items_tabs.edit.click() assert magic_items_edit.item.get_attribute( 'value').strip() == 'Adamantine Armor' armor_type = 'Armor (medium or heavy but not hide)' assert magic_items_edit.type_.get_attribute('value').strip() == armor_type assert magic_items_edit.rarity.get_attribute('value').strip() == 'Uncommon' assert magic_items_edit.max_charges.get_attribute('value').strip() == '0' assert magic_items_edit.weight.get_attribute('value').strip() == '0' assert magic_items_edit.requires_attunement.is_selected() is False description = magic_items_edit.description.get_attribute('value').strip() assert 'reinforced with adamantine' in description
def test_strength_increase(player_wizard, browser): # noqa """When strength is increased or decreased, relevant skills, savings throws, to hit, and encumbrance reflect the change.""" print(('When strength is increased or decreased, relevant skills, savings ' 'throws, to hit, and encumbrance reflect the change.')) saving_throw = SavingThrowTable(browser) skills = SkillsTable(browser) ability_scores_table = AbilityScoresTable(browser) ability_scores_edit = AbilityScoresEditModal(browser) hud = HUD(browser) weapon_table = WeaponTable(browser) weapon_add = WeaponAddModal(browser) tabs = Tabs(browser) ability_scores_table.table.click() ability_scores_edit.strength = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 5)) strength = ut.get_table_row(saving_throw, 'table', row_number=5) tabs.skills.click() athletics = ut.get_table_row(skills, 'table', row_number=4) tabs.equipment.click() weapon_table.add.click() # select battleaxe ut.select_from_autocomplete(weapon_add, 'name', browser, has_search_term=False) weapon_add.add.click() to_hit = ut.get_table_row(weapon_table, 'table').to_hit status = hud.status_line.find_elements_by_tag_name('span') encumbrance_color = status[1].get_attribute('class') assert strength.blank2.strip() == '+ 2' assert to_hit.strip() == '+ 4' assert athletics.blank2.strip() == '+ 2 (Str)' assert 'text-info' in encumbrance_color
def test_weapon_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from weapon name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from weapon name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) weapon_add = weapon.WeaponAddModal(browser) weapon_table = weapon.WeaponTable(browser) tabs = Tabs(browser) tabs.equipment.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, weapon_table.add_id) ) ) weapon_table.add.click() ut.select_from_autocomplete( weapon_add, 'name', browser, has_search_term=False ) weapon_add.add.click() row = ut.get_table_row(weapon_table, 'table', 1) assert row.weapon.strip().strip() == 'Battleaxe' assert row.to_hit.strip() == '+ 6' assert row.damage.strip() == '1d8 or 1d10' assert row.damage_type.strip() == 'Slashing' assert row.range.strip() == '5 ft.' assert row.property.strip() == 'Versatile' assert row.quantity.strip() == '1'
def test_weapon_magical_modifier(player_wizard, browser): # noqa """As a player, if weapon is magical, a badge indicating the modifier is present.""" print(('As a player, if weapon is magical, a badge indicating the ' 'modifier is present.')) weapon_add = weapon.WeaponAddModal(browser) weapon_table = weapon.WeaponTable(browser) tabs = Tabs(browser) tabs.equipment.click() weapon_table.add.click() weapon_add.name = 'Add Name' weapon_add.magical_modifier = 3 WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, weapon_table.add_id) ) ) weapon_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) row = ut.get_table_row(weapon_table, 'table', 1) weapon_name_label = ' '.join([string.strip() for string in row.weapon.split()]) assert weapon_name_label == 'Add Name + 3'
def test_armor_donned(player_wizard, browser): # noqa """As a player, the checkbox appears when armor is donned.""" print('As a player, the checkbox appears when armor is donned.') 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.don.click() armor_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(armor_table)) row = ut.get_table_row(armor_table, 'table', 1, values=False) assert 'fa fa-check' in row[0].find_element_by_tag_name( 'span').get_attribute('class').strip()
def test_reach_ft(player_wizard, browser): # noqa """As a player, if I add a weapon with property reach, 5 ft. is added after I close the modal.""" print(('As a player, if I add a weapon with property reach, 5 ft. is ' 'added after I close the modal')) weapon_add = weapon.WeaponAddModal(browser) weapon_table = weapon.WeaponTable(browser) tabs = Tabs(browser) tabs.equipment.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, weapon_table.add_id) ) ) weapon_table.add.click() weapon_add.name = 'Test name' weapon_add.type_ = 'Melee' weapon_add.property_ = 'Reach' weapon_add.range_ = '5' weapon_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) row = ut.get_table_row(weapon_table, 'table', values=False) assert row[4].text.strip() == '10 ft.'
def test_armor_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from armor name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from armor name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) 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(table_has_data(armor_table)) row = ut.get_table_row(armor_table, 'table', 1) assert row.armor.strip() == 'Breastplate' assert row.armor_class.strip() == '14' assert row.type.strip() == 'Medium'
def test_add_feature(player_wizard, browser): # noqa """As a player, I can add a feature.""" print('As a player, I can add a feature.') feature = features.FeatureAddModal(browser) features_table = features.FeaturesTable(browser) tracked_table = tracked.TrackedTable(browser) tabs = Tabs(browser) tabs.skills.click() features_table.add.click() feature.name = 'Add Name' feature.class_ = 'Add Class' feature.level = 1 feature.description = 'Add Description' feature.tracked.click() feature.max_ = 4 feature.short_rest.click() assert feature.name.get_attribute('value').strip() == 'Add Name' assert feature.class_.get_attribute('value').strip() == 'Add Class' assert feature.level.get_attribute('value').strip() == '1' assert feature.description.get_attribute( 'value').strip() == 'Add Description' assert feature.max_.get_attribute('value').strip() == '4' assert 'active' in feature.short_rest.get_attribute('class').strip() feature.add.click() row = ut.get_table_row(features_table, 'table', 1) assert tracked_table.tracked1_name.text.strip() == 'Add Name' assert tracked_table.tracked1_max.text.strip() == '4' assert row.class_.strip() == 'Add Class' assert row.feature.strip() == 'Add Name'
def test_add_feat(player_wizard, browser): # noqa """As a player, I can add a feat.""" print('As a player, I can add a feat.') feat = feats.FeatAddModal(browser) feats_table = feats.FeatsTable(browser) tracked_table = tracked.TrackedTable(browser) tabs = Tabs(browser) tabs.skills.click() feats_table.add.click() feat.name = 'Add Name' feat.description = 'Add Description' feat.tracked.click() feat.max_ = 4 feat.short_rest.click() assert feat.name.get_attribute('value').strip() == 'Add Name' assert feat.description.get_attribute('value').strip() == 'Add Description' assert feat.max_.get_attribute('value').strip() == '4' assert 'active' in feat.short_rest.get_attribute('class').strip() feat.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(feats_table)) row = ut.get_table_row(feats_table, 'table', 1) assert tracked_table.tracked1_name.text.strip() == 'Add Name' assert tracked_table.tracked1_max.text.strip() == '4' assert row.feat.strip() == 'Add Name'
def test_add_trait(player_wizard, browser): # noqa """As a player, I can add a trait.""" print('As a player, I can add a trait.') trait = traits.TraitAddModal(browser) traits_table = traits.TraitsTable(browser) tracked_table = tracked.TrackedTable(browser) tabs = Tabs(browser) tabs.skills.click() traits_table.add.click() trait.name = 'Add Name' trait.race = 'Add Race' trait.description = 'Add Description' trait.tracked.click() trait.max_ = 4 trait.short_rest.click() assert trait.name.get_attribute('value').strip() == 'Add Name' assert trait.race.get_attribute('value').strip() == 'Add Race' assert trait.description.get_attribute( 'value').strip() == 'Add Description' assert trait.max_.get_attribute('value').strip() == '4' assert 'active' in trait.short_rest.get_attribute('class').strip() trait.add.click() row = ut.get_table_row(traits_table, 'table', 1) assert tracked_table.tracked1_name.text.strip() == 'Add Name' assert tracked_table.tracked1_max.text.strip() == '4' assert row.race.strip() == 'Add Race' assert row.trait.strip() == 'Add Name'
def test_inventory_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from inventory name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from inventory name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) inventory_add = inventory.InventoryAddModal(browser) inventory_table = inventory.InventoryTable(browser) tabs = Tabs(browser) tabs.inventory.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, inventory_table.add_id))) inventory_table.add.click() ut.select_from_autocomplete(inventory_add, 'name', browser, has_search_term=False) inventory_add.add.click() row = ut.get_table_row(inventory_table, 'table', 1) assert row.item.strip() == 'Abacus' assert row.weight.strip() == '2 lbs.' assert row.quantity.strip() == '1' assert row.cost.strip() == '2 GP' assert row.description.strip() == ''
def test_magical_modifier(player_wizard, browser): # noqa """As a player, if armor is magical, a badge indicating the modifier is present.""" print(('As a player, if armor is magical, a badge indicating the ' 'modifier is present.')) armor_add = armor.ArmorAddModal(browser) armor_table = armor.ArmorTable(browser) tabs = Tabs(browser) tabs.equipment.click() stub = ArmorFactory.stub() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, armor_table.add_id) ) ) armor_table.add.click() armor_add.name = stub.name armor_add.magical_modifier = stub.magical_modifier armor_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) row = ut.get_table_row(armor_table, 'table', 1) actual = ' '.join([string.strip() for string in row.armor.split()]) assert actual == '{} + {}'.format(stub.name, stub.magical_modifier)
def test_proficiency_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from proficiency name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from proficiency name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) proficiency_add = proficiency.ProficiencyAddModal(browser) proficiency_table = proficiency.ProficiencyTable(browser) tabs = Tabs(browser) tabs.skills.click() 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)) row = ut.get_table_row(proficiency_table, 'table', 1) assert row.type.strip() == 'Languages' assert row.proficiency.strip() == 'Abyssal'
def test_armor_donned(player_wizard, browser): # noqa """As a player, the checkbox appears when armor is donned.""" print('As a player, the checkbox appears when armor is donned.') armor_add = armor.ArmorAddModal(browser) armor_table = armor.ArmorTable(browser) tabs = Tabs(browser) tabs.equipment.click() stub = ArmorFactory.stub() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, armor_table.add_id) ) ) armor_table.add.click() armor_add.name = stub.name armor_add.don.click() armor_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) row = ut.get_table_row(armor_table, 'table', 1, values=False) assert 'fa fa-check' in row[0].find_element_by_tag_name('span').get_attribute('class').strip()
def test_add_proficiency(player_wizard, browser): # noqa """As a player, I can add a proficiency.""" print('As a player, I can add a proficiency.') proficiency_add = proficiency.ProficiencyAddModal(browser) proficiency_table = proficiency.ProficiencyTable(browser) tabs = Tabs(browser) tabs.skills.click() proficiency_table.add.click() proficiency_add.name = 'Add Name' proficiency_add.type_ = 'Add Type' proficiency_add.description = 'Add Description' assert proficiency_add.name.get_attribute('value').strip() == 'Add Name' assert proficiency_add.type_.get_attribute('value').strip() == 'Add Type' assert proficiency_add.description.get_attribute( 'value').strip() == 'Add Description' proficiency_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(proficiency_table)) row = ut.get_table_row(proficiency_table, 'table', 1) assert row.type.strip() == 'Add Type' assert row.proficiency.strip() == 'Add Name'
def test_feature_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from feature name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from feature name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) 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(table_has_data(features_table)) row = ut.get_table_row(features_table, 'table', 1) assert row.class_.strip() == 'Barbarian' assert 'Rage' in row.feature.strip()
def test_trait_ogl_pre_pop(player_wizard, browser): # noqa """As a player, if I select from trait name field, OGL data auto-completes and the remaining fields pre-populate.""" print(('As a player, if I select from trait name field, OGL data ' 'auto-completes and the remaining fields pre-populate.')) trait = traits.TraitAddModal(browser) traits_table = traits.TraitsTable(browser) tabs = Tabs(browser) tabs.skills.click() 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(table_has_data(traits_table)) row = ut.get_table_row(traits_table, 'table', 1) assert row.race.strip() == 'Dragonborn' assert row.trait.strip() == 'Ability Score Increase'
def test_add_armor(player_wizard, browser): # noqa """As a player, I can add an armor.""" print('As a player, I can add an armor.') armor_add = armor.ArmorAddModal(browser) armor_table = armor.ArmorTable(browser) tabs = Tabs(browser) tabs.equipment.click() stub = ArmorFactory.stub() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, armor_table.add_id))) armor_table.add.click() armor_add.name = stub.name armor_add.type_ = stub.type_ armor_add.magical_modifier = stub.magical_modifier armor_add.price = stub.price armor_add.currency_denomination = stub.currency_denomination armor_add.weight = stub.weight armor_add.armor_class = stub.armor_class armor_add.stealth = stub.stealth armor_add.stealth.send_keys(Keys.TAB) armor_add.don.click() armor_add.description = stub.description assert armor_add.name.get_attribute('value').strip() == stub.name assert armor_add.type_.get_attribute('value').strip() == stub.type_ assert int(armor_add.magical_modifier.get_attribute( 'value').strip()) == stub.magical_modifier assert int(armor_add.price.get_attribute('value').strip()) == stub.price curr_denomination = stub.currency_denomination assert armor_add.currency_denomination.get_attribute( 'value').strip() == curr_denomination assert int(armor_add.weight.get_attribute('value').strip()) == stub.weight assert int(armor_add.armor_class.get_attribute( 'value').strip()) == stub.armor_class assert armor_add.stealth.get_attribute('value').strip() == stub.stealth assert 'active' in armor_add.don.get_attribute('class').strip() assert armor_add.description.get_attribute( 'value').strip() == stub.description armor_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(table_has_data(armor_table)) row = ut.get_table_row(armor_table, 'table', 1) armor_name_label = ' '.join( [string.strip() for string in row.armor.split()]) assert armor_name_label == '{} + {}'.format(stub.name, stub.magical_modifier) assert int(row.armor_class.strip()) == stub.armor_class assert row.type.strip() == stub.type_
def test_preview_magic_items(player_wizard, browser): # noqa """As a player, I can select a row in the magic_items table and view the item in the preview tab.""" print(('As a player, I can select a row in the magic_items table and view ' ' the item in the preview tab')) magic_items_add = magic_items.MagicItemsAddModal(browser) magic_items_table = magic_items.MagicItemsTable(browser) magic_items_preview = magic_items.MagicItemsPreviewModal(browser) tabs = Tabs(browser) tabs.inventory.click() magic_items_table.add.click() ut.select_from_autocomplete( magic_items_add, 'item', browser, has_search_term=False ) magic_items_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( modal_finished_closing() ) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_has_data(magic_items_table) ) row = ut.get_table_row(magic_items_table, 'table', values=False) row[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element( (By.ID, magic_items_preview.item_id), 'Adamantine Armor' ) ) preview_type_ = magic_items_preview.type_.text.split() magic_items_type = ' '.join([string.strip() for string in preview_type_]) magic_items_max_charges = ' '.join( [ string.strip() for string in magic_items_preview.max_charges.text.split() ] ) magic_items_weight = ' '.join( [ string.strip() for string in magic_items_preview.weight.text.split() ] ) assert magic_items_preview.item.text.strip() == 'Adamantine Armor' assert magic_items_preview.rarity.text.strip() == 'Uncommon' assert magic_items_type == 'Type: Armor (medium or heavy but not hide)' assert magic_items_max_charges == 'Max Charges: 0' assert magic_items_weight == 'Weight: 0 lbs.' assert 'reinforced with adamantine' in magic_items_preview.description.text.strip()
def test_add_magic_items(player_wizard, browser): # noqa """As a player, I can add an item to my magic_items.""" print('As a player, I can add an item to my magic_items.') magic_items_add = magic_items.MagicItemsAddModal(browser) magic_items_table = magic_items.MagicItemsTable(browser) tabs = Tabs(browser) tabs.inventory.click() magic_items_table.add.click() magic_items_add.item = 'Add Name' magic_items_add.type_ = 'Add Armor' magic_items_add.rarity = 'Add Rare' magic_items_add.max_charges = 3 magic_items_add.charges = 3 magic_items_add.weight = 100 magic_items_add.requires_attunement.click() magic_items_add.attuned.click() magic_items_add.description = 'Add Description' assert magic_items_add.item.get_attribute('value').strip() == 'Add Name' assert magic_items_add.type_.get_attribute('value').strip() == 'Add Armor' assert magic_items_add.rarity.get_attribute('value').strip() == 'Add Rare' assert magic_items_add.max_charges.get_attribute('value').strip() == '3' assert magic_items_add.charges.get_attribute('value').strip() == '3' assert magic_items_add.weight.get_attribute('value').strip() == '100' assert magic_items_add.requires_attunement.is_selected() assert magic_items_add.attuned.is_selected() assert magic_items_add.description.get_attribute('value').strip() == 'Add Description' magic_items_add.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_has_data(magic_items_table) ) row = ut.get_table_row(magic_items_table, 'table', 1) assert row.magic_item.strip() == 'Add Name' assert row.charges.strip() == '3' assert row.weight.strip() == '100 lbs.' assert row.description.strip() == 'Add Description' row = ut.get_table_row(magic_items_table, 'table', 1, values=False) assert row[2].find_element_by_tag_name('input').is_selected()
def test_edit_trait(player_wizard, browser): # noqa """As a player, I can edit a trait.""" print('As a player, I can edit a trait.') trait = traits.TraitAddModal(browser) trait_edit = traits.TraitEditModal(browser) traits_table = traits.TraitsTable(browser) trait_tabs = traits.TraitModalTabs(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.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) rows = ut.get_table_rows(traits_table, 'table', values=False) rows[0][0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, trait_tabs.edit_id))) trait_tabs.edit.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.presence_of_element_located((By.ID, trait_edit.name_id))) trait_edit.name = 'Edited Name' trait_edit.race = 'Edited Race' trait_edit.description = 'Edited Description' trait_edit.tracked.click() trait_edit.max_ = 4 trait_edit.short_rest.click() assert trait_edit.name.get_attribute('value').strip() == 'Edited Name' assert trait_edit.race.get_attribute('value').strip() == 'Edited Race' assert trait_edit.description.get_attribute( 'value').strip() == 'Edited Description' assert trait_edit.max_.get_attribute('value').strip() == '4' assert 'active' in trait_edit.short_rest.get_attribute('class').strip() trait_edit.done.click() rows = ut.get_table_rows(traits_table, 'table', values=False) WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(traits_table, 'trait', 'Edited Name', 'table', 1)) row = ut.get_table_row(traits_table, 'table', 1) assert row.trait.strip() == 'Edited Name' assert row.race.strip() == 'Edited Race'
def test_add_weapon(player_wizard, browser): # noqa """As a player, I can add a weapon.""" print('As a player, I can add a weapon.') weapon_add = weapon.WeaponAddModal(browser) weapon_table = weapon.WeaponTable(browser) tabs = Tabs(browser) tabs.equipment.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.ID, weapon_table.add_id) ) ) weapon_table.add.click() weapon_add.name = 'Add Name' weapon_add.damage = 'Add Damage' weapon_add.magical_modifier = 1 weapon_add.to_hit_modifier = 2 weapon_add.type_ = 'Ranged' weapon_add.handedness = 'Add Handedness' weapon_add.proficiency = 'Add Proficiency' weapon_add.price = 200 weapon_add.currency_denomination = 'GP' weapon_add.weight = 100 weapon_add.range_ = '20/40' weapon_add.damage_type = 'Add Damage Type' weapon_add.property_ = 'Add Property' weapon_add.quantity = 2 weapon_add.description = 'Add Description' assert weapon_add.name.get_attribute('value').strip() == 'Add Name' assert weapon_add.damage.get_attribute('value').strip() == 'Add Damage' assert weapon_add.magical_modifier.get_attribute('value').strip() == '1' assert weapon_add.to_hit_modifier.get_attribute('value').strip() == '2' assert weapon_add.handedness.get_attribute('value').strip() == 'Add Handedness' assert weapon_add.proficiency.get_attribute('value').strip() == 'Add Proficiency' assert weapon_add.price.get_attribute('value').strip() == '200' assert weapon_add.currency_denomination.get_attribute('value').strip() == 'GP' assert weapon_add.weight.get_attribute('value').strip() == '100' assert weapon_add.range_.get_attribute('value').strip() == '20/40' assert weapon_add.damage_type.get_attribute('value').strip() == 'Add Damage Type' assert weapon_add.property_.get_attribute('value').strip() == 'Add Property' assert weapon_add.quantity.get_attribute('value').strip() == '2' assert weapon_add.description.get_attribute('value').strip() == 'Add Description' weapon_add.add.click() row = ut.get_table_row(weapon_table, 'table', 1) assert ' '.join(row.weapon.split()) == 'Add Name + 1' assert row.to_hit.strip() == '+ 9' assert row.damage.strip() == 'Add Damage' assert row.damage_type.strip() == 'Add Damage Type' assert row.range.strip() == '20/40 ft.' assert row.property.strip() == 'Add Property' assert row.quantity.strip() == '2'