def test_health_bar_changes_color(player_wizard, browser): # noqa """As a player, I can see the hit points bar change colors at certain intervals as hit points decrease.""" print(('As a player, I can see the hit points bar change colors at ' 'certain intervals as hit points decrease.')) health = HitPointHitDice(browser) hp_bar_class = health.hit_points_bar_regular_hp.get_attribute( 'class').strip() assert 'progress-bar-danger' not in hp_bar_class health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() time.sleep(.5) health.damage_up.click() assert 'progress-bar-danger' in health.hit_points_bar_regular_hp.get_attribute( 'class').strip()
def test_character_stable_alert(player_wizard, browser): # noqa """If 3 death save success are clicked, an alert indicating the player is stable is presented.""" print(('If 3 death save success are clicked, an alert indicating the ' 'player is stable is presented.')) time.sleep(3) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): time.sleep(1) hp_hd.damage_up.click() successes = hp_hd.death_successes_empty successes[0].click() successes = hp_hd.death_successes_empty successes[0].click() successes = hp_hd.death_successes_empty successes[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element((By.XPATH, hp_hd.toast_title_xpath), 'You are now stable.')) assert hp_hd.toast_title.text.strip() == 'You are now stable.' assert hp_hd.toast_message.text.strip( ) == 'You have been spared...for now.'
def test_character_dead_alert(player_wizard, browser): # noqa """If 3 death save success are clicked, an alert indicating the player is dead is presented.""" print(('If 3 death save success are clicked, an alert indicating the ' 'player is dead is presented.')) time.sleep(3) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): hp_hd.damage_up.click() time.sleep(1) failures = hp_hd.death_failures_empty failures[0].click() failures = hp_hd.death_failures_empty failures[0].click() failures = hp_hd.death_failures_empty failures[0].click() WebDriverWait(browser, DEFAULT_WAIT_TIME).until( EC.text_to_be_present_in_element((By.XPATH, hp_hd.toast_title_xpath), 'You have died.')) assert hp_hd.toast_title.text.strip() == 'You have died.' assert hp_hd.toast_message.text.strip( ) == 'Failing all 3 death saves will do that...'
def test_death_saves_clickable(player_wizard, browser): # noqa """As a player, death save successes and failures are clickable and images change when clicked.""" print(('As a player, death save successes and failures are clickable and ' 'images change when clicked.')) time.sleep(3) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): time.sleep(1) hp_hd.damage_up.click() time.sleep(2) success = hp_hd.death_successes_empty[0] success.click() failure = hp_hd.death_failures_empty[0] failure.click() time.sleep(1) assert len(browser.find_elements_by_class_name('ds-success-full')) == 1 assert len(browser.find_elements_by_class_name('ds-failure-full')) == 1
def test_death_saves_persist(player_wizard, browser): # noqa """As a player, death save changes persist after I refresh the browser.""" print(('As a player, death save changes persist after I refresh the ' 'browser.')) time.sleep(3) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): time.sleep(1) hp_hd.damage_up.click() success = hp_hd.death_successes_empty[0] success.click() failure = hp_hd.death_failures_empty[0] failure.click() browser.refresh() time.sleep(1) assert len(hp_hd.death_successes_empty) == 2 assert len(hp_hd.death_failures_empty) == 2
def test_hit_dice_clickable(player_wizard, browser): # noqa """As a player, hit dice are clickable and images change when clicked.""" print(('As a player, hit dice are clickable and images change when ' 'clicked.')) hp_hd = HitPointHitDice(browser) assert hp_hd.hitdice1.get_attribute('class').strip() == 'dice-full' hp_hd.hitdice1.click() assert hp_hd.hitdice1.get_attribute('class').strip() == 'dice-empty'
def test_hp_reset(player_wizard, browser): # noqa """As a player, I can reset my hp by clicking on the reset icon.""" print('As a player, I can reset my hp by clicking on the reset icon.') hp_hd = HitPointHitDice(browser) hp_hd.damage_up.click() assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 9' hp_hd.reset.click() assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 10'
def test_hit_dice_persists(player_wizard, browser): # noqa """As a player, if I click on a hit die, the changes persist after I refresh the browser.""" print(('As a player, if I click on a hit die, the changes persist after I ' 'refresh the browser.')) hp_hd = HitPointHitDice(browser) hp_hd.hitdice1.click() assert hp_hd.hitdice1.get_attribute('class').strip() == 'dice-empty' browser.refresh() assert hp_hd.hitdice1.get_attribute('class').strip() == 'dice-empty'
def test_hp_stepper(player_wizard, browser): # noqa """As a player, I can increase or decrease my hit points via the stepper widget.""" print(('As a player, I can increase or decrease my hit points via the ' 'stepper widget.')) hp_hd = HitPointHitDice(browser) hp_hd.damage_up.click() assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 9' hp_hd.damage_down.click() assert hp_hd.hit_points_bar_label.text.strip() == 'HP: 10'
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_character_dead_alert(player_wizard, browser): # noqa """If 3 death save success are clicked, an alert indicating the player is dead is presented.""" print(('If 3 death save success are clicked, an alert indicating the ' 'player is dead is presented.')) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): hp_hd.damage_up.click() failures = hp_hd.death_failures_empty failures[0].click() failures[1].click() failures[2].click() assert hp_hd.toast_title.text.strip() == 'You have died.' assert hp_hd.toast_message.text.strip( ) == 'Failing all 3 death saves will do that...'
def test_character_stable_alert(player_wizard, browser): # noqa """If 3 death save success are clicked, an alert indicating the player is stable is presented.""" print(('If 3 death save success are clicked, an alert indicating the ' 'player is stable is presented.')) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): hp_hd.damage_up.click() successes = hp_hd.death_successes_empty successes[0].click() successes[1].click() successes[2].click() assert hp_hd.toast_title.text.strip() == 'You are now stable.' assert hp_hd.toast_message.text.strip( ) == 'You have been spared...for now.'
def test_death_saves_clickable(player_wizard, browser): # noqa """As a player, death save successes and failures are clickable and images change when clicked.""" print(('As a player, death save successes and failures are clickable and ' 'images change when clicked.')) hp_hd = HitPointHitDice(browser) # reduce character to 0 hit points for _ in range(10): hp_hd.damage_up.click() success = hp_hd.death_successes_empty[0] success.click() failure = hp_hd.death_failures_empty[0] failure.click() assert success.get_attribute('class').strip() == 'ds-success-full' assert failure.get_attribute('class').strip() == 'ds-failure-full'
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'