def test_initiative_modifier(player_wizard, browser): # noqa """As a player, I can increase or decrease my calculated initiative via a modifier field and this is reflected in the label.""" print(('As a player, I can increase or decrease my calculated initiative ' 'via a modifier field and this is reflected in the label.')) time.sleep(3) other_stats = OtherStats(browser) other_stats.edit_btn.click() other_stats.initiative_modifier_input = 1 other_stats.initiative_modifier_input.send_keys(Keys.TAB) other_stats.save_btn.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element( (By.XPATH, other_stats.initiative_label_xpath), '5')) assert other_stats.initiative_label.text.strip() == '5' other_stats.edit_btn.click() other_stats.initiative_modifier_input = -1 other_stats.initiative_modifier_input.send_keys(Keys.TAB) other_stats.save_btn.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element( (By.XPATH, other_stats.initiative_label_xpath), '3')) assert other_stats.initiative_label.text.strip() == '3'
def test_proficieny_bonus_calculation(player_wizard, browser): # noqa """As a player, proficieny bonus is correctly calculated.""" print('As a player, proficieny bonus is correctly calculated.') other_stats = OtherStats(browser) other_stats.level = 5 other_stats.level.send_keys(Keys.TAB) assert other_stats.proficiency_bonus.text.strip() == '3'
def test_ac_modifier(player_wizard, browser): # noqa """As a player, I can increase or decrease my calculated armor class via a modifier field and this is reflected in the label.""" print(('As a player, I can increase or decrease my calculated armor class ' 'via a modifier field and this is reflected in the label.')) other_stats = OtherStats(browser) other_stats.ac_modifier = 1 other_stats.ac_modifier.send_keys(Keys.TAB) assert other_stats.ac.text.strip() == '15'
def test_inpiration_blue_circle(player_wizard, browser): # noqa """As a player, if I am inspired, there should be a blue circle around my profice pic.""" print(('As a player, if I am inspired, there should be a blue circle ' 'around my profice pic.')) other_stats = OtherStats(browser) profile_pic = ProfilePicture(browser) other_stats.inspiration = 1 other_stats.inspiration.send_keys(Keys.TAB) assert 'image-border-inspired' in profile_pic.profile_pic_border.get_attribute( 'class').strip()
def test_proficiency_modifier(player_wizard, browser): # noqa """As a player, I can increase or decrease my calculated proficiency via a modifier field and this is reflected in the label.""" print(('As a player, I can increase or decrease my calculated proficiency ' 'via a modifier field and this is reflected in the label.')) other_stats = OtherStats(browser) other_stats.level = 5 other_stats.level.send_keys(Keys.TAB) other_stats.proficiency_bonus_modifier = 1 other_stats.proficiency_bonus_modifier.send_keys(Keys.TAB) assert other_stats.proficiency_bonus.text.strip() == '4'
def test_inpiration_blue_circle(player_wizard, browser): # noqa """As a player, if I am inspired, there should be a blue circle around my profice pic.""" print(('As a player, if I am inspired, there should be a blue circle ' 'around my profice pic.')) time.sleep(2) other_stats = OtherStats(browser) profile_pic = ProfilePicture(browser) other_stats.edit_btn.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.element_to_be_clickable( (By.XPATH, other_stats.inspiration_input_xpath))) other_stats.inspiration_input.click() other_stats.ac_modifier_input.send_keys(Keys.TAB) other_stats.save_btn.click() time.sleep(4) assert 'image-border-inspired' in profile_pic.profile_pic_border.get_attribute( 'class').strip()
def test_initiative_calculation(player_wizard, browser): # noqa """As a player, initiative is correctly calculated.""" print('As a player, initiative is correctly calculated.') other_stats = OtherStats(browser) assert other_stats.initiative.text.strip() == '4'
def test_hit_dice_level(player_wizard, browser): # noqa """As a player, if I change the value in the level field, the number of hit dice match the level number.""" print(('As a player, if I change the value in the level field, the number ' 'of hit dice match the level number.')) hp_hd = HitPointHitDice(browser) other_stats = OtherStats(browser) other_stats.level = 3 other_stats.level.send_keys(Keys.TAB) hit_dice_count = len(hp_hd.hit_dice_list.find_elements_by_tag_name('span')) assert hit_dice_count == 3
def test_initiative_modifier(player_wizard, browser): # noqa """As a player, I can increase or decrease my calculated initiative via a modifier field and this is reflected in the label.""" print(('As a player, I can increase or decrease my calculated initiative ' 'via a modifier field and this is reflected in the label.')) other_stats = OtherStats(browser) other_stats.initiative_modifier = 1 other_stats.initiative_modifier.send_keys(Keys.TAB) assert other_stats.initiative.text.strip() == '5' other_stats.initiative_modifier = -1 other_stats.initiative_modifier.send_keys(Keys.TAB) assert other_stats.initiative.text.strip() == '3'
def test_wizard_profile_stats(browser): # noqa """As a player, after creating a character via the character creation wizard, I can view all the data entered in the stats and profile modules.""" print( 'As a player, after creating a character via the character creation wizard, I can view all the data entered in the stats and profile modules.' ) wizard_main = NewCharacterCampaign(browser) who_are_you = wizard.WhoAreYou(browser) ability_scores = wizard.AbilityScoresManual(browser) tabs = Tabs(browser) profile = Profile(browser) stats = OtherStats(browser) hud = HUD(browser) wizard_main.get_started.click() wizard_main.player.click() wizard_main.next_.click() who_are_you.character_name = 'Test Char' who_are_you.player_name = 'Automated Testing Bot.' ut.select_from_autocomplete(who_are_you, 'alignment', '', browser) who_are_you.deity = 'Test Deity' ut.select_from_autocomplete(who_are_you, 'race', '', browser) ut.select_from_autocomplete(who_are_you, 'class_', '', browser) who_are_you.gender = 'Test Male' who_are_you.age = 21 ut.select_from_autocomplete(who_are_you, 'background', '', browser) who_are_you.level = 3 who_are_you.experience = 1000 wizard_main.next_.click() ability_scores.strength = '18' ability_scores.dexterity = '18' ability_scores.constitution = '18' ability_scores.intelligence = '18' ability_scores.wisdom = '18' ability_scores.charisma = '18' wizard_main.finish.click() tabs.profile.click() assert profile.name.get_attribute('value') == 'Automated Testing Bot.' assert profile.background.get_attribute('value') == 'Acolyte' assert profile.alignment.get_attribute('value') == 'Lawful good' assert profile.deity.get_attribute('value') == 'Test Deity' assert profile.race.get_attribute('value') == 'Dwarf' assert profile.class_.get_attribute('value') == 'Barbarian' assert profile.gender.get_attribute('value') == 'Test Male' assert profile.age.get_attribute('value') == '21' tabs.stats.click() assert stats.level.get_attribute('value') == '3' assert stats.experience.get_attribute('value') == '1000'
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_proficieny_bonus_calculation(player_wizard, browser): # noqa """As a player, proficieny bonus is correctly calculated.""" print('As a player, proficieny bonus is correctly calculated.') time.sleep(3) other_stats = OtherStats(browser) other_stats.edit_btn.click() other_stats.level_input = 5 other_stats.level_input.send_keys(Keys.TAB) other_stats.save_btn.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element( (By.XPATH, other_stats.proficiency_bonus_label_xpath), '3')) assert other_stats.proficiency_bonus_label.text.strip() == '3'
def test_proficiency_popover(player_wizard, browser): # noqa """As a player, I can can click on a popover showing the calculation for Proficiency Bonus.""" print(('As a player, I can can click on a popover showing the calculation ' 'for Proficiency Bonus.')) other_stats = OtherStats(browser) other_stats.proficiency_popover_icon.click() # safari has no newline, so it must be stripped popover = other_stats.proficiency_popover_content.text.strip() popover = popover.replace('\n', '') assert popover == 'Proficiency = (Level / 4) + 1 + ModifierProficiency = 1 + 1 + 0'
def test_initiative_popover(player_wizard, browser): # noqa """As a player, I can can click on a popover showing the calculation for Initiative.""" print(('As a player, I can can click on a popover showing the calculation ' 'for Initiative.')) other_stats = OtherStats(browser) other_stats.initiative_popover_icon.click() # safari has no newline, so it must be stripped popover = other_stats.initiative_popover_content.text.strip() popover = popover.replace('\n', '') assert popover == 'Initiative = Dexterity Modifier + ModifierInitiative = 4 + 0'
def test_ac_popover(player_wizard, browser): # noqa """As a player, I can can click on a popover showing the calculation for Armor Class.""" print(('As a player, I can can click on a popover showing the calculation ' 'for Armor Class.')) other_stats = OtherStats(browser) other_stats.ac_popover_icon.click() # safari has no newline, so it must be stripped popover = other_stats.proficiency_popover_content.text.strip() popover = popover.replace('\n', '') assert popover == ( 'Armor Class = Base AC + Dexterity Modifier + Magical Modifier(s) + ' 'Shield + ModifierArmor Class = 10 + 4 + 0 + 0 + 0')
def test_data_persists(player_wizard, browser): # noqa """As a player, all changes I make to hit points, hit dice, ability scores, savings throws, and other stats persist after I refresh the browser.""" print(('As a player, all changes I make to hit points, hit dice, ability ' 'scores, savings throws, and other stats persist after I refresh ' ' the browser.')) time.sleep(8) ability_scores_edit = AbilityScoresEditModal(browser) ability_scores_table = AbilityScoresTable(browser) hp_hd = HitPointHitDice(browser) other_stats = OtherStats(browser) saving_throw = SavingThrowTable(browser) saving_throw_edit = SavingThrowEditModal(browser) ability_scores_table.table.click() ability_scores_edit.strength = 15 ability_scores_edit.strength.send_keys(Keys.TAB) ability_scores_edit.done.click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing()) hp_hd.damage_up.click() hp_hd.hitdice1.click() row = ut.get_table_row(saving_throw, 'table', values=False) # open edit modal row[0].click() saving_throw_edit.modifier = 1 saving_throw_edit.proficiency.click() saving_throw_edit.done.click() time.sleep(3) other_stats.edit_btn.click() other_stats.ac_modifier_input = 1 other_stats.ac_modifier_input.send_keys(Keys.TAB) other_stats.initiative_modifier_input = 1 other_stats.initiative_modifier_input.send_keys(Keys.TAB) other_stats.proficiency_bonus_input = 1 other_stats.proficiency_bonus_input.send_keys(Keys.TAB) other_stats.speed_input = 40 other_stats.speed_input.send_keys(Keys.TAB) other_stats.level_input = 3 other_stats.level_input.send_keys(Keys.TAB) other_stats.experience_input = 2000 time.sleep(1) other_stats.experience_input.send_keys(Keys.TAB) other_stats.inspiration_input.click() other_stats.save_btn.click() time.sleep(2) browser.refresh() time.sleep(10) row = ut.get_table_row(saving_throw, 'table', values=False) proficiency = row[0].find_elements(By.TAG_NAME, 'span') assert ability_scores_table.strength.text.strip() == '15' assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 9' assert hp_hd.hitdice3.get_attribute('class').strip() == 'dice-empty' assert proficiency[0].get_attribute('class').strip() == 'fa fa-check' assert other_stats.initiative_label.text.strip() == '5' assert other_stats.proficiency_bonus_label.text.strip() == '3' assert other_stats.speed_label.text.strip() == '40' assert other_stats.level_label.text.strip() == '3' assert other_stats.experience_label.text.strip() == '2000'