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_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_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_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_edit_feat(player_wizard, browser): # noqa """As a player, I can edit a feat.""" print('As a player, I can edit a feat.') feat = feats.FeatAddModal(browser) feat_edit = feats.FeatEditModal(browser) feats_table = feats.FeatsTable(browser) feat_tabs = feats.FeatModalTabs(browser) tabs = Tabs(browser) tabs.skills.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, feats_table.add_id))) feats_table.add.click() ut.select_from_autocomplete(feat, 'name', browser, has_search_term=False) feat.name.send_keys(Keys.TAB) feat.add.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) rows = ut.get_table_rows(feats_table, 'table', values=False) rows[0][0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, feat_tabs.edit_id))) feat_tabs.edit.click() feat_tabs.edit.click() feat_edit.name = 'Edited Name' feat_edit.description = 'Edited Description' feat_edit.tracked.click() feat_edit.max_ = 4 feat_edit.short_rest.click() assert feat_edit.name.get_attribute('value').strip() == 'Edited Name' assert feat_edit.description.get_attribute( 'value').strip() == 'Edited Description' assert feat_edit.max_.get_attribute('value').strip() == '4' assert 'active' in feat_edit.short_rest.get_attribute('class').strip() feat_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(feats_table, 'feat', 'Edited Name', 'table', 1)) row = ut.get_table_row(feats_table, 'table', 1) assert row.feat.strip() == 'Edited Name'
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_constitution_increase(player_wizard, browser): # noqa """When constitution is increased or decreased, relevant skills reflect the change.""" print(('When constitution is increased or decreased, relevant skills ' 'reflect the change.')) saving_throw = SavingThrowTable(browser) ability_scores_table = AbilityScoresTable(browser) ability_scores_edit = AbilityScoresEditModal(browser) ability_scores_table.table.click() ability_scores_edit.constitution = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 2)) constitution = ut.get_table_row(saving_throw, 'table', row_number=2) assert constitution.blank2.strip() == '+ 2'
def test_wisdom_increase(player_wizard, browser): # noqa """When wisdom is increased or decreased, relevant skills and savings throws reflect the change.""" print(('When wisdom 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.wisdom = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 6)) wisdom = ut.get_table_row(saving_throw, 'table', row_number=6) tabs.skills.click() animal_handling = ut.get_table_row(skills, 'table', row_number=2) insight = ut.get_table_row(skills, 'table', row_number=7) medicine = ut.get_table_row(skills, 'table', row_number=10) perception = ut.get_table_row(skills, 'table', row_number=12) survival = ut.get_table_row(skills, 'table', row_number=18) assert wisdom.blank2.strip() == '+ 2' assert animal_handling.blank2.strip() == '+ 2 (Wis)' assert insight.blank2.strip() == '+ 2 (Wis)' assert medicine.blank2.strip() == '+ 2 (Wis)' assert perception.blank2.strip() == '+ 2 (Wis)' assert survival.blank2.strip() == '+ 2 (Wis)'
def test_intelligence_increase(player_wizard, browser): # noqa """When intelligence is increased or decreased, relevant skills reflect the change.""" print(('When intelligence is increased or decreased, relevant skills ' '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.intelligence = 14 ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(saving_throw, 'blank2', '+ 2', 'table', 4)) intelligence = ut.get_table_row(saving_throw, 'table', row_number=4) tabs.skills.click() arcana = ut.get_table_row(skills, 'table', row_number=3) history = ut.get_table_row(skills, 'table', row_number=6) investigation = ut.get_table_row(skills, 'table', row_number=9) nature = ut.get_table_row(skills, 'table', row_number=11) religion = ut.get_table_row(skills, 'table', row_number=15) assert intelligence.blank2.strip() == '+ 2' assert arcana.blank2.strip() == '+ 2 (Int)' assert history.blank2.strip() == '+ 2 (Int)' assert investigation.blank2.strip() == '+ 2 (Int)' assert nature.blank2.strip() == '+ 2 (Int)' assert religion.blank2.strip() == '+ 2 (Int)'
def test_edit_armor(player_wizard, browser): # noqa """As a player, I can edit an armor.""" print('As a player, I can edit an armor.') 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() stub = ArmorFactory.stub() 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][0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable((By.ID, armor_tabs.edit_id))) armor_tabs.edit.click() armor_edit.name = stub.name armor_edit.type_ = stub.type_ armor_edit.magical_modifier = stub.magical_modifier armor_edit.price = stub.price armor_edit.currency_denomination = stub.currency_denomination armor_edit.weight = stub.weight armor_edit.armor_class = stub.armor_class armor_edit.stealth = stub.stealth armor_edit.stealth.send_keys(Keys.TAB) armor_edit.doff.click() armor_edit.description = stub.description assert armor_edit.name.get_attribute('value').strip() == stub.name assert armor_edit.type_.get_attribute('value').strip() == stub.type_ assert int(armor_edit.magical_modifier.get_attribute( 'value').strip()) == stub.magical_modifier assert int(armor_edit.price.get_attribute('value').strip()) == stub.price curr_denomination = stub.currency_denomination assert armor_edit.currency_denomination.get_attribute( 'value').strip() == curr_denomination assert int(armor_edit.weight.get_attribute('value').strip()) == stub.weight assert int(armor_edit.armor_class.get_attribute( 'value').strip()) == stub.armor_class assert armor_edit.stealth.get_attribute('value').strip() == stub.stealth assert 'active' in browser.find_element( By.ID, armor_add.doff_id).get_attribute('class').strip() assert armor_edit.description.get_attribute( 'value').strip() == stub.description armor_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) WebDriverWait(browser, DEFAULT_WAIT_TIME).until( table_cell_updated(armor_table, 'armor', '{} + {}'.format(stub.name, stub.magical_modifier), 'table', 1)) row = ut.get_table_row(armor_table, 'table', 1) armor_field = ' '.join([string.strip() for string in row.armor.split()]) assert armor_field == '{} + {}'.format(stub.name, stub.magical_modifier) assert int(row.armor_class.strip()) == stub.armor_class assert row.type.strip() == stub.type_