示例#1
0
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'
示例#2
0
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.'))

    time.sleep(3)

    other_stats = OtherStats(browser)

    other_stats.edit_btn.click()

    other_stats.level_input = 5
    other_stats.proficiency_bonus_input = 1
    other_stats.proficiency_bonus_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), '4'))

    assert other_stats.proficiency_bonus_label.text.strip() == '4'
示例#3
0
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.'))

    time.sleep(3)

    hp_hd = HitPointHitDice(browser)
    other_stats = OtherStats(browser)

    other_stats.edit_btn.click()

    other_stats.level_input = 3
    other_stats.level_input.send_keys(Keys.TAB)

    other_stats.save_btn.click()

    time.sleep(3)

    hit_dice_count = len(hp_hd.hit_dice_list.find_elements_by_tag_name('span'))

    assert hit_dice_count == 3
示例#4
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'