Example #1
0
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') == 'Add Name'
    assert proficiency_add.type_.get_attribute('value') == 'Add Type'
    assert proficiency_add.description.get_attribute(
        'value') == 'Add Description'

    proficiency_add.add.click()

    row = ut.get_table_row(proficiency_table, 'table', 1)
    assert row.type == 'Add Type'
    assert row.proficiency == 'Add Name'
Example #2
0
def test_delete_feature(player_wizard, browser):  # noqa
    """As a player, I can delete a feature."""
    print('As a player, I can delete a feature.')

    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.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    rows = ut.get_table_rows(features_table, 'table', values=False)

    rows[0][2].click()
    rows = ut.get_table_rows(features_table, 'table', values=False)

    assert rows[0][0].text.strip() == 'Add a new Feature'
Example #3
0
def test_autocomplete_proficiency(player_wizard, browser):  # noqa
    """As a player, if I start typing in the name field and class field, I can
       select suggested items in the dropdown."""
    print(
        ('As a player, if I start typing in the name field and type field, I '
         'can select suggested items in the dropdown.'))

    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)
    ut.select_from_autocomplete(proficiency_add,
                                'type_',
                                browser,
                                has_search_term=False)

    assert proficiency_add.name.get_attribute('value').strip() == 'Abyssal'
    assert proficiency_add.type_.get_attribute('value').strip() == 'Armor'
Example #4
0
def test_add_autocomplete_feature(player_wizard, browser):  # noqa
    """As a player, if I start typing in the name field and class field,
       I can select suggested items in the dropdown."""
    print(('As a player, if I start typing in the name field and class field, '
           'I can select suggested items in the dropdown.'))

    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)
    ut.select_from_autocomplete(feature,
                                'class_',
                                browser,
                                has_search_term=False)

    assert feature.name.get_attribute(
        'value').strip() == 'Rage (Barbarian, Lvl. 1)'
    assert feature.class_.get_attribute('value').strip() == 'Barbarian'
Example #5
0
def test_magic_items_total_weight(player_wizard, browser):  # noqa
    """As a player, in the magic_items table, total weight is calculated correctly."""
    print(
        'As a player, in the armor table, total weight is calculated correctly'
    )

    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()
    ut.select_from_autocomplete(magic_items_add, 'item', 'b', browser)
    magic_items_add.weight = 5
    magic_items_add.add.click()

    time.sleep(.3)

    magic_items_table.add.click()
    ut.select_from_autocomplete(magic_items_add, 'item', 'b', browser)
    magic_items_add.weight = 10
    magic_items_add.add.click()

    assert magic_items_table.total_weight.text == '15 (lbs)'
Example #6
0
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()

    time.sleep(.5)

    browser.refresh()

    time.sleep(.5)

    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() == '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
Example #7
0
def test_autocomplete_weapon(player_wizard, browser): # noqa
    """As a player, if I start typing in the autocomplete inputs, I can select
       suggested items in the dropdown."""
    print(('As a player, if I start typing in the autocomplete inputs, I can '
           ' select suggested items in the dropdown.'))

    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
    )
    ut.select_from_autocomplete(
        weapon_add,
        'type_',
        browser,
        has_search_term=False
    )
    ut.select_from_autocomplete(
        weapon_add,
        'handedness',
        browser,
        has_search_term=False
    )
    ut.select_from_autocomplete(
        weapon_add,
        'proficiency',
        browser,
        has_search_term=False
    )
    ut.select_from_autocomplete(
        weapon_add,
        'damage_type',
        browser,
        has_search_term=False
    )
    ut.select_from_autocomplete(
        weapon_add,
        'property_',
        browser,
        has_search_term=False
    )

    assert weapon_add.name.get_attribute('value').strip() == 'Battleaxe'
    assert weapon_add.type_.get_attribute('value').strip() == 'Melee'
    assert weapon_add.handedness.get_attribute('value').strip() == 'One or Two Handed'
    assert weapon_add.proficiency.get_attribute('value').strip() == 'Martial'
    assert weapon_add.damage_type.get_attribute('value').strip() == 'Acid'
    assert weapon_add.property_.get_attribute('value').strip() == 'Ammunition'
Example #8
0
def test_edit_magic_items(player_wizard, browser):  # noqa
    """As a player, I can edit an item in my magic_items."""
    print('As a player, I can edit an item in my magic_items.')

    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()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    rows = ut.get_table_rows(magic_items_table, 'table', values=False)
    rows[0][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()

    magic_items_edit.item = 'Edit Name'
    magic_items_edit.type_ = 'Edit Armor'
    magic_items_edit.rarity = 'Edit Rare'
    magic_items_edit.max_charges = 3
    magic_items_edit.charges = 3
    magic_items_edit.weight = 100
    magic_items_edit.requires_attunement.click()
    magic_items_edit.attuned.click()
    magic_items_edit.description = 'Edit Description'

    assert magic_items_edit.item.get_attribute('value').strip() == 'Edit Name'
    assert magic_items_edit.type_.get_attribute(
        'value').strip() == 'Edit Armor'
    assert magic_items_edit.rarity.get_attribute(
        'value').strip() == 'Edit Rare'
    assert magic_items_edit.max_charges.get_attribute('value').strip() == '3'
    assert magic_items_edit.charges.get_attribute('value').strip() == '3'
    assert magic_items_edit.weight.get_attribute('value').strip() == '100'
    assert magic_items_edit.requires_attunement.is_selected()
    assert magic_items_edit.attuned.is_selected()
    assert magic_items_edit.description.get_attribute(
        'value').strip() == 'Edit Description'

    magic_items_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    row = ut.get_table_row(magic_items_table, 'table', 1)

    assert row.magic_item.strip() == 'Edit Name'
    assert row.charges.strip() == '3'
    assert row.weight.strip() == '100 lbs.'
    assert row.description.strip() == 'Edit Description'

    row = ut.get_table_row(magic_items_table, 'table', 1, values=False)

    assert row[2].find_element_by_tag_name('input').is_selected()
Example #9
0
def test_weapon_sorting(player_wizard, browser):  # noqa
    """As a player, I can sort the weapon table by clicking on the sortable columns."""
    print(
        'As a player, I can sort the weapon table by clicking on the sortable columns'
    )

    weapon_add = weapon.WeaponAddModal(browser)
    weapon_table = weapon.WeaponTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    weapon_table.add.click()
    ut.select_from_autocomplete(weapon_add, 'name', '', browser)
    weapon_add.add.click()

    time.sleep(.3)
    weapon_table.add.click()
    ut.select_from_autocomplete(weapon_add,
                                'name',
                                '',
                                browser,
                                arrow_down_count=2)
    weapon_add.add.click()

    time.sleep(.3)
    weapon_table.weapon_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[0].text.strip() == 'Blowgun'

    time.sleep(.3)
    weapon_table.to_hit_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[1].text.strip() == '+ 6'

    time.sleep(.3)
    weapon_table.damage_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[2].text.strip() == '1'

    time.sleep(.3)
    weapon_table.damage_type_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[3].text.strip() == 'Piercing'

    time.sleep(.3)
    weapon_table.damage_type_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[3].text.strip() == 'Slashing'

    time.sleep(.3)
    weapon_table.range_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[4].text.strip() == '5 ft.'

    time.sleep(.3)
    weapon_table.property_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[5].text.strip() == 'Ranged, Ammunition, and Loading'

    time.sleep(.3)
    weapon_table.quantity_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(weapon_table, 'table', values=False)
    assert rows[6].text.strip() == '1'
Example #10
0
def test_edit_spells(player_wizard, browser):  # noqa
    """As a player, I can edit a spells."""
    print('As a player, I can edit a spells.')

    spells_add = spells.SpellsAddModal(browser)
    spells_edit = spells.SpellsEditModal(browser)
    spells_table = spells.SpellsTable(browser)
    spells_tabs = spells.SpellsModalTabs(browser)
    tabs = Tabs(browser)
    tabs.spells.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, spells_table.add_id)))

    spells_table.add.click()

    ut.select_from_autocomplete(spells_add,
                                'name',
                                browser,
                                has_search_term=False)
    spells_add.description.click()
    spells_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    rows = ut.get_table_rows(spells_table, 'table', values=False)
    rows[0][1].click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, spells_tabs.edit_id)))

    spells_tabs.edit.click()
    spells_tabs.edit.click(
    )  # Added as cludge, not sure why click would only work sporadically

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.presence_of_element_located((By.ID, spells_edit.name_id)))

    time.sleep(1)

    spells_edit.name = 'Add Name'
    spells_edit.prepared.click()
    spells_edit.level = '5'
    spells_edit.school = 'Add School'
    spells_edit.type_ = 'Savings Throw'
    spells_edit.save_attr = 'Con'
    spells_edit.damage = '1d4'
    spells_edit.cast_time = '1 action'
    spells_edit.range_ = '5 feet'
    spells_edit.components = 'S'
    spells_edit.material_components = 'Add Material'
    spells_edit.duration = '12 Minutes'
    spells_edit.description = ' Add Description'

    assert spells_edit.name.get_attribute('value') == 'Add Name'
    assert spells_edit.prepared.is_selected()
    assert spells_edit.level.get_attribute('value') == '5'
    assert spells_edit.school.get_attribute('value') == 'Add School'
    assert spells_edit.type_.get_attribute('value') == 'Savings Throw'
    assert spells_edit.save_attr.get_attribute('value') == 'Con'
    assert spells_edit.damage.get_attribute('value') == '1d4'
    assert spells_edit.cast_time.get_attribute('value') == '1 action'
    assert spells_edit.range_.get_attribute('value') == '5 feet'
    assert spells_edit.components.get_attribute('value') == 'S'
    assert spells_edit.material_components.get_attribute(
        'value') == 'Add Material'
    assert spells_edit.duration.get_attribute('value') == '12 Minutes'
    assert spells_edit.description.get_attribute('value') == ' Add Description'

    spells_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    time.sleep(1)

    row = ut.get_table_row(spells_table, 'table', 1)

    assert row.spell == 'Add Name'
    assert row.level == '5'
    assert row.type == 'Savings Throw'
    assert row.damage == '1d4'
    assert row.casting_time == '1 action'
    assert row.range == '5 feet'

    row = ut.get_table_row(spells_table, 'table', 1, values=False)

    assert row[0].find_element_by_tag_name('input').is_selected()
Example #11
0
def test_data_persists(player_wizard, browser):  # noqa
    """As a player, all changes I make to features, feats, traits,
       proficiencies, tracking, and skills persist after I refresh the
       browser."""

    print(('As a player, all changes I make to features, feats, traits, '
           'proficiencies, tracking, and skills persist after I refresh the '
           'browser.'))

    feature = features.FeatureAddModal(browser)
    features_table = features.FeaturesTable(browser)
    feat = feats.FeatAddModal(browser)
    feats_table = feats.FeatsTable(browser)
    trait = traits.TraitAddModal(browser)
    traits_table = traits.TraitsTable(browser)
    tracked_table = tracked.TrackedTable(browser)
    proficiency_add = proficiency.ProficiencyAddModal(browser)
    proficiency_table = proficiency.ProficiencyTable(browser)
    skills_table = skills.SkillsTable(browser)
    skills_edit = skills.SkillsEditModal(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()

    time.sleep(1)

    feature.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    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())

    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(modal_finished_closing())

    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(modal_finished_closing())

    acrobatics = ut.get_table_row(skills_table, 'table', values=False)
    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())

    browser.refresh()

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(features_table))

    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'

    row = ut.get_table_row(feats_table, 'table', 1)

    assert row.feat.strip() == 'Grappler'

    row = ut.get_table_row(traits_table, 'table', 1)

    assert row.race.strip() == 'Dragonborn'
    assert row.trait.strip() == 'Ability Score Increase'

    row = ut.get_table_row(proficiency_table, 'table', 1)

    assert row.type.strip() == 'Languages'
    assert row.proficiency.strip() == 'Abyssal'
Example #12
0
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.name.send_keys(Keys.TAB)

    trait.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(traits_table))

    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'
Example #13
0
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.name.send_keys(Keys.TAB)

    weapon_add.add.click()

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(weapon_table))

    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'
Example #14
0
def test_armor_sorting(player_wizard, browser):  # noqa
    """As a player, I can sort the armor table by clicking on the sortable
       columns."""
    print(('As a player, I can sort the armor table by clicking on the '
           'sortable columns'))

    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(modal_finished_closing())

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add,
                                'name',
                                browser,
                                arrow_down_count=2,
                                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))

    armor_table.armor_header.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_down(armor_table.armor_header_sorting_arrow, ))

    time.sleep(.5)

    rows = ut.get_table_row(armor_table, 'table', values=False)

    assert rows[1].text.strip() == 'Chain mail'

    armor_table.type_header.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(armor_table.type_header_sorting_arrow, ))

    rows = ut.get_table_row(armor_table, 'table', values=False)

    assert rows[2].text.strip() == 'Heavy'
Example #15
0
def test_edit_weapon(player_wizard, browser):  # noqa
    """As a player, I can edit a weapon."""
    print('As a player, I can edit a weapon.')

    weapon_add = weapon.WeaponAddModal(browser)
    weapon_edit = weapon.WeaponEditModal(browser)
    weapon_table = weapon.WeaponTable(browser)
    weapon_tabs = weapon.WeaponModalTabs(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.name.send_keys(Keys.TAB)

    weapon_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(weapon_table))

    rows = ut.get_table_rows(weapon_table, 'table', values=False)
    rows[0][0].click()

    time.sleep(1)

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, weapon_tabs.edit_id)))

    weapon_tabs.edit.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.presence_of_element_located((By.ID, weapon_edit.name_id)))

    weapon_edit.name = 'Edit Name'
    weapon_edit.damage = '1d10'
    weapon_edit.magical_modifier = 2
    weapon_edit.to_hit_modifier = 2
    weapon_edit.type_ = 'Melee'
    weapon_edit.handedness = 'One-Handed'
    weapon_edit.proficiency = 'Simple'
    weapon_edit.price = 200
    weapon_edit.currency_denomination = 'GP'
    weapon_edit.weight = 200
    weapon_edit.range_ = 5
    weapon_edit.damage_type = 'Slashing'
    weapon_edit.property_ = 'Versatile'
    weapon_edit.quantity = 2
    weapon_edit.description = 'Edit Description'

    assert weapon_edit.name.get_attribute('value').strip() == 'Edit Name'
    assert weapon_edit.damage.get_attribute('value').strip() == '1d10'
    assert weapon_edit.magical_modifier.get_attribute('value').strip() == '2'
    assert weapon_edit.to_hit_modifier.get_attribute('value').strip() == '2'
    assert weapon_edit.type_.get_attribute('value').strip() == 'Melee'
    assert weapon_edit.handedness.get_attribute(
        'value').strip() == 'One-Handed'
    assert weapon_edit.proficiency.get_attribute('value').strip() == 'Simple'
    assert weapon_edit.price.get_attribute('value').strip() == '200'
    assert weapon_edit.currency_denomination.get_attribute(
        'value').strip() == 'GP'
    assert weapon_edit.weight.get_attribute('value').strip() == '200'
    assert weapon_edit.range_.get_attribute('value').strip() == '5'
    assert weapon_edit.damage_type.get_attribute('value').strip() == 'Slashing'
    assert weapon_edit.property_.get_attribute('value').strip() == 'Versatile'
    assert weapon_edit.quantity.get_attribute('value').strip() == '2'
    assert weapon_edit.description.get_attribute(
        'value').strip() == 'Edit Description'

    weapon_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    time.sleep(.5)

    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 == 'Edit Name + 2'
    assert row.to_hit.strip() == '+ 10'
    assert row.damage.strip() == '1d10'
    assert row.damage_type.strip() == 'Slashing'
    assert row.range.strip() == '5 ft.'
    assert row.property.strip() == 'Versatile'
    assert row.quantity.strip() == '2'
Example #16
0
def test_edit_inventory(player_wizard, browser): # noqa
    """As a player, I can edit an item in my inventory."""
    print('As a player, I can edit an item in my inventory.')

    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()

    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()
    )

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        table_has_data(inventory_table)
    )

    rows = ut.get_table_rows(inventory_table, 'table', values=False)
    rows[0][0].click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable(
            (By.ID, inventory_tabs.edit_id)
        )
    )

    inventory_tabs.edit.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.presence_of_element_located(
            (By.ID, inventory_edit.name_id)
        )
    )

    inventory_edit.name = 'Edit Name'
    inventory_edit.weight = 100
    inventory_edit.quantity = 2
    inventory_edit.cost = 100
    inventory_edit.currency_denomination = 'GP'
    inventory_edit.description = 'Edit Description'

    assert inventory_edit.name.get_attribute('value').strip() == 'Edit Name'
    assert inventory_edit.weight.get_attribute('value').strip() == '100'
    assert inventory_edit.quantity.get_attribute('value').strip() == '2'
    assert inventory_edit.cost.get_attribute('value').strip() == '100'
    assert inventory_edit.currency_denomination.get_attribute('value').strip() == 'GP'
    assert inventory_edit.description.get_attribute('value').strip() == 'Edit Description'

    inventory_edit.done.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        modal_finished_closing()
    )

    time.sleep(1)

    row = ut.get_table_row(inventory_table, 'table', 1)

    assert row.item.strip() == 'Edit Name'
    assert row.quantity.strip() == '2'
    assert row.weight.strip() == '100 lbs.'
    assert row.cost.strip() == '100 GP'
    assert row.description.strip() == 'Edit Description'
Example #17
0
def test_edit_feature(player_wizard, browser):  # noqa
    """As a player, I can edit a feature."""
    print('As a player, I can edit a feature.')

    feature = features.FeatureAddModal(browser)
    feature_edit = features.FeatureEditModal(browser)
    features_table = features.FeaturesTable(browser)
    feature_tabs = features.FeatureModalTabs(browser)
    tabs = Tabs(browser)
    tabs.skills.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, features_table.add_id)))

    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(modal_finished_closing())

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(features_table))

    rows = ut.get_table_rows(features_table, 'table', values=False)
    rows[0][0].click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, feature_tabs.edit_id)))

    feature_tabs.edit.click()
    # Clicking twice is required for unknown reason
    feature_tabs.edit.click()

    feature_edit.name = 'Edited Name'
    feature_edit.class_ = 'Edited Class'
    feature_edit.level = 1
    feature_edit.description = 'Edited Description'
    feature_edit.tracked.click()
    feature_edit.max_ = 4
    feature_edit.short_rest.click()

    assert feature_edit.name.get_attribute('value').strip() == 'Edited Name'
    assert feature_edit.class_.get_attribute('value').strip() == 'Edited Class'
    assert feature_edit.level.get_attribute('value').strip() == '1'
    assert feature_edit.description.get_attribute(
        'value').strip() == 'Edited Description'
    assert feature_edit.max_.get_attribute('value').strip() == '4'
    assert 'active' in feature_edit.short_rest.get_attribute('class').strip()

    feature_edit.done.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    time.sleep(1)

    row = ut.get_table_row(features_table, 'table', 1)

    assert row.feature.strip() == 'Edited Name'
    assert row.class_.strip() == 'Edited Class'
Example #18
0
def test_weapon_persists(player_wizard, browser):  # noqa
    """As a player, all fields for weapon persist after page refresh."""
    print('As a player, all fields for weapon persist after page refresh.')

    weapon_add = weapon.WeaponAddModal(browser)
    weapon_edit = weapon.WeaponEditModal(browser)
    weapon_table = weapon.WeaponTable(browser)
    weapon_tabs = weapon.WeaponModalTabs(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.name.send_keys(Keys.TAB)

    weapon_add.add.click()

    browser.refresh()

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(weapon_table))

    # TODO need a custom wait until to hit is + 6, for some reason it's + 4 at first
    time.sleep(3)

    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'

    row = ut.get_table_row(weapon_table, 'table', values=False)
    row[0].click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, weapon_tabs.edit_id)))

    time.sleep(3)

    weapon_tabs.edit.click()

    assert weapon_edit.name.get_attribute('value').strip() == 'Battleaxe'
    assert weapon_edit.damage.get_attribute('value').strip() == '1d8 or 1d10'
    assert weapon_edit.magical_modifier.get_attribute('value').strip() == '0'
    assert weapon_edit.to_hit_modifier.get_attribute('value').strip() == '0'
    assert weapon_edit.type_.get_attribute('value').strip() == 'Melee'
    assert weapon_edit.handedness.get_attribute(
        'value').strip() == 'One or Two Handed'
    assert weapon_edit.proficiency.get_attribute('value').strip() == 'Martial'
    assert weapon_edit.price.get_attribute('value').strip() == '10'
    assert weapon_edit.currency_denomination.get_attribute(
        'value').strip() == 'GP'
    assert weapon_edit.weight.get_attribute('value').strip() == '4'
    assert weapon_edit.range_.get_attribute('value').strip() == ''
    assert weapon_edit.damage_type.get_attribute('value').strip() == 'Slashing'
    assert weapon_edit.property_.get_attribute('value').strip() == 'Versatile'
    assert weapon_edit.quantity.get_attribute('value').strip() == '1'
    assert weapon_edit.description.get_attribute('value').strip() == ''
Example #19
0
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()

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(skills_table))

    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()
Example #20
0
def test_weapon_sorting(player_wizard, browser):  # noqa
    """As a player, I can sort the weapon table by clicking on the
       sortable columns."""
    print(('As a player, I can sort the weapon table by clicking on the '
           ' sortable columns'))

    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.name.send_keys(Keys.TAB)

    weapon_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(weapon_table))

    weapon_table.add.click()
    ut.select_from_autocomplete(weapon_add,
                                'name',
                                browser,
                                has_search_term=False,
                                arrow_down_count=2)

    weapon_add.name.send_keys(Keys.TAB)

    weapon_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    weapon_table.weapon_header.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_down(weapon_table.weapon_header_sorting_arrow, ))

    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[0].text.strip() == 'Blowgun'

    weapon_table.to_hit_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.to_hit_header_sorting_arrow, ))

    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[1].text.strip() == '+ 6'

    weapon_table.damage_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.damage_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[2].text.strip() == '1'

    weapon_table.damage_type_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.damage_type_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[3].text.strip() == 'Piercing'

    weapon_table.damage_type_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_down(weapon_table.damage_type_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[3].text.strip() == 'Slashing'

    weapon_table.range_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.range_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[4].text.strip() == '5 ft.'

    weapon_table.property_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.property_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[5].text.strip() == 'Ranged, Ammunition, and Loading'

    weapon_table.quantity_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(weapon_table.quantity_header_sorting_arrow, ))
    rows = ut.get_table_row(weapon_table, 'table', values=False)

    assert rows[6].text.strip() == '1'
Example #21
0
def test_profile_and_appearance_persists(player_wizard, browser):
    """Profile inputs should persist data."""
    print('As a player, profile inputs persist data.')
    profile_edit = ProfileEdit(browser)
    profile_view = ProfileView(browser)

    appearance_edit = AppearanceEdit(browser)
    appearance_view = AppearanceView(browser)

    tabs = Tabs(browser)
    tabs.profile.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element(
            (By.XPATH, profile_view.alignment_xpath),
            'No Alignment'
        )
    )

    profile_edit.edit_btn.click()

    profile_edit.alignment = 'Chaotic Good'

    assert profile_edit.alignment.get_attribute('value').strip() == 'Chaotic Good'

    profile_edit.deity = 'Moridin'

    assert profile_edit.deity.get_attribute('value').strip() == 'Moridin'

    profile_edit.race = 'Gnome'

    assert profile_edit.race.get_attribute('value').strip() == 'Gnome'

    profile_edit.class_ = 'Fighter'

    assert profile_edit.class_.get_attribute('value').strip() == 'Fighter'

    profile_edit.gender = 'Male'

    assert profile_edit.gender.get_attribute('value').strip() == 'Male'

    profile_edit.age = '12'

    assert profile_edit.age.get_attribute('value').strip() == '12'

    appearance_edit.weight = '165'

    assert appearance_edit.weight.get_attribute('value').strip() == '165'

    appearance_edit.hair_color = 'Brown'

    assert appearance_edit.hair_color.get_attribute('value').strip() == 'Brown'

    appearance_edit.eye_color = 'Brown'

    assert appearance_edit.eye_color.get_attribute('value').strip() == 'Brown'

    appearance_edit.skin_color = 'Fair'

    assert appearance_edit.skin_color.get_attribute('value').strip() == 'Fair'

    profile_edit.save_btn.click()

    browser.refresh()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element(
            (By.XPATH, profile_view.alignment_xpath),
            'Chaotic Good'
        )
    )

    assert profile_view.alignment.text.strip() == 'Chaotic Good'
    assert profile_view.deity.text.strip() == 'Moridin'
    assert profile_view.race.text.strip() == 'Gnome'
    assert profile_view.class_.text.strip() == 'Fighter'
    assert profile_view.gender.text.strip() == 'Male'
    assert profile_view.age.text.strip() == '12'
    assert appearance_view.weight.text.strip() == '165'
    assert appearance_view.hair_color.text.strip() == 'Brown'
    assert appearance_view.eye_color.text.strip() == 'Brown'
    assert appearance_view.skin_color.text.strip() == 'Fair'
Example #22
0
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_
Example #23
0
def test_add_spells(player_wizard, browser):  # noqa
    """As a player, I can add a spells."""
    print('As a player, I can add a spells.')

    spells_add = spells.SpellsAddModal(browser)
    spells_table = spells.SpellsTable(browser)
    tabs = Tabs(browser)
    tabs.spells.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, spells_table.add_id)))

    spells_table.add.click()
    spells_add.name = 'Acid Arrow'
    spells_add.name.send_keys(Keys.TAB)

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.invisibility_of_element_located(
            (By.CLASS_NAME, 'ui-menu-item-wrapper')))

    spells_add.prepared.click()
    spells_add.level = '5'
    spells_add.school = 'Add School'
    spells_add.type_ = 'Savings Throw'
    spells_add.save_attr = 'Dex'
    spells_add.damage = '1d4'
    spells_add.cast_time = '1 action'
    spells_add.range_ = '5 feet'
    spells_add.components = 'S'
    spells_add.material_components = 'Add Material'
    spells_add.duration = '12 Minutes'
    spells_add.description = ' Add Description'

    assert spells_add.name.get_attribute('value').strip() == 'Acid Arrow'
    assert spells_add.prepared.is_selected()
    assert spells_add.level.get_attribute('value').strip() == '5'
    assert spells_add.school.get_attribute('value').strip() == 'Add School'
    assert spells_add.type_.get_attribute('value').strip() == 'Savings Throw'
    assert spells_add.save_attr.get_attribute('value').strip() == 'Dex'
    assert spells_add.damage.get_attribute('value').strip() == '1d4'
    assert spells_add.cast_time.get_attribute('value').strip() == '1 action'
    assert spells_add.range_.get_attribute('value').strip() == '5 feet'
    assert spells_add.components.get_attribute('value').strip() == 'S'
    assert spells_add.material_components.get_attribute(
        'value').strip() == 'Add Material'
    assert spells_add.duration.get_attribute('value').strip() == '12 Minutes'

    spells_add.add.click()

    WebDriverWait(browser,
                  DEFAULT_WAIT_TIME).until(table_has_data(spells_table))

    row = ut.get_table_row(spells_table, 'table', 1)

    assert row.spell.strip() == 'Acid Arrow'
    assert row.level.strip() == '5'
    assert row.type.strip() == 'Savings Throw'
    assert row.damage.strip() == '1d4'
    assert row.casting_time.strip() == '1 action'
    assert row.range.strip() == '5 feet'

    row = ut.get_table_row(spells_table, 'table', 1, values=False)
Example #24
0
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)

    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,
                                has_search_term=False)
    who_are_you.deity = 'Test Deity'
    ut.select_from_autocomplete(who_are_you,
                                'race',
                                browser,
                                has_search_term=False)
    ut.select_from_autocomplete(who_are_you,
                                'class_',
                                browser,
                                has_search_term=False)
    who_are_you.gender = 'Test Male'
    who_are_you.age = 21
    ut.select_from_autocomplete(who_are_you,
                                'background',
                                browser,
                                has_search_term=False)
    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').strip() == 'Automated Testing Bot.'
    assert profile.background.get_attribute('value').strip() == 'Acolyte'
    assert profile.alignment.get_attribute('value').strip() == 'Lawful good'
    assert profile.deity.get_attribute('value').strip() == 'Test Deity'
    assert profile.race.get_attribute('value').strip() == 'Dwarf'
    assert profile.class_.get_attribute('value').strip() == 'Barbarian'
    assert profile.gender.get_attribute('value').strip() == 'Test Male'
    assert profile.age.get_attribute('value').strip() == '21'

    tabs.stats.click()

    assert stats.level.get_attribute('value') == '3'
    assert stats.experience.get_attribute('value') == '1000'
Example #25
0
def test_edit_weapon(player_wizard, browser):  # noqa
    """As a player, I can edit a weapon."""
    print('As a player, I can edit a weapon.')

    weapon_add = weapon.WeaponAddModal(browser)
    weapon_edit = weapon.WeaponEditModal(browser)
    weapon_table = weapon.WeaponTable(browser)
    weapon_tabs = weapon.WeaponModalTabs(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    weapon_table.add.click()
    ut.select_from_autocomplete(weapon_add, 'name', '', browser)
    weapon_add.add.click()

    rows = ut.get_table_rows(weapon_table, 'table', values=False)
    time.sleep(.3)
    rows[0][0].click()
    time.sleep(.3)
    weapon_tabs.edit.click()
    time.sleep(.3)

    weapon_edit.name = 'Edit Name'
    weapon_edit.damage = '1d10'
    weapon_edit.magical_modifier = 2
    weapon_edit.to_hit_modifier = 2
    weapon_edit.type_ = 'Melee'
    weapon_edit.handedness = 'One-Handed'
    weapon_edit.proficiency = 'Simple'
    weapon_edit.price = 200
    weapon_edit.currency_denomination = 'GP'
    weapon_edit.weight = 200
    weapon_edit.range_ = 5
    weapon_edit.damage_type = 'Slashing'
    weapon_edit.property_ = 'Versatile'
    weapon_edit.quantity = 2
    weapon_edit.description = 'Edit Description'

    assert weapon_edit.name.get_attribute('value') == 'Edit Name'
    assert weapon_edit.damage.get_attribute('value') == '1d10'
    assert weapon_edit.magical_modifier.get_attribute('value') == '2'
    assert weapon_edit.to_hit_modifier.get_attribute('value') == '2'
    assert weapon_edit.type_.get_attribute('value') == 'Melee'
    assert weapon_edit.handedness.get_attribute('value') == 'One-Handed'
    assert weapon_edit.proficiency.get_attribute('value') == 'Simple'
    assert weapon_edit.price.get_attribute('value') == '200'
    assert weapon_edit.currency_denomination.get_attribute('value') == 'GP'
    assert weapon_edit.weight.get_attribute('value') == '200'
    assert weapon_edit.range_.get_attribute('value') == '5'
    assert weapon_edit.damage_type.get_attribute('value') == 'Slashing'
    assert weapon_edit.property_.get_attribute('value') == 'Versatile'
    assert weapon_edit.quantity.get_attribute('value') == '2'
    assert weapon_edit.description.get_attribute('value') == 'Edit Description'
    weapon_edit.done.click()
    time.sleep(.3)
    row = ut.get_table_row(weapon_table, 'table', 1)
    assert row.weapon == 'Edit Name  + 2'
    assert row.to_hit == '+ 10'
    assert row.damage == '1d10'
    assert row.damage_type == 'Slashing'
    assert row.range == '5 ft.'
    assert row.property == 'Versatile'
    assert row.quantity == '2'
Example #26
0
def test_wizard_backpack_prepop(browser):  # noqa
    """As a player, after selecting a backpack, all items are pre-populated in the inventory
       module."""
    print((
        'As a player, after selecting a backpack, all items are pre-populated in the '
        'inventory module.'))

    wizard_main = NewCharacterCampaign(browser)
    who_are_you = wizard.WhoAreYou(browser)
    ability_scores = wizard.AbilityScoresManual(browser)
    tabs = Tabs(browser)
    inventory_table = inventory.InventoryTable(browser)

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, wizard_main.get_started_id)))

    wizard_main.get_started.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, wizard_main.player_id)))

    wizard_main.player.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, wizard_main.next_id)))

    wizard_main.next_.click()

    who_are_you.character_name = 'Test Char'
    who_are_you.player_name = 'Automated Testing Bot.'

    backpack = Select(browser.find_element_by_id(who_are_you.backpack_id))
    backpack.select_by_index(1)

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, wizard_main.next_id)))

    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()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, tabs.inventory_id)))

    tabs.inventory.click()

    # Safari has known issue where selects not working
    # https://forums.developer.apple.com/message/184592#184592
    # Javascript example not working either
    if browser.name != 'safari':
        WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
            table_has_data(inventory_table, ))

        rows = ut.get_table_rows(inventory_table, 'table')

        assert rows[0].item.strip() == 'Backpack'
        assert rows[0].quantity.strip() == '1'
        assert rows[0].weight.strip() == '5 lbs.'
        assert rows[0].cost.strip() == '2 GP'
        assert rows[0].description.strip() == ''

        assert rows[1].item.strip() == 'Ball bearings (bag of 1000)'
        assert rows[2].item.strip() == 'Bell'
        assert rows[3].item.strip() == 'Candle'
        assert rows[4].item.strip() == 'Crowbar'
        assert rows[5].item.strip() == 'Hammer'
        assert rows[6].item.strip() == 'Lantern hooded'
        assert rows[7].item.strip() == 'Oil (flask)'
        assert rows[8].item.strip() == 'Piton'
        assert rows[9].item.strip() == 'Rations (1 day)'
        assert rows[10].item.strip() == 'Rope hempen (50 feet)'
        assert rows[11].item.strip() == 'String (10 feet)'
        assert rows[12].item.strip() == 'Tinderbox'

        assert rows[13].item.strip() == 'Waterskin'
        assert rows[13].quantity.strip() == '1'
        assert rows[13].weight.strip() == '5 lbs.'
        assert rows[13].cost.strip() == '2 SP'
        assert rows[13].description.strip() == '(full)'
Example #27
0
def test_magic_items_sorting(player_wizard, browser):  # noqa
    """As a player, I can sort the magic_items table by clicking on the
       sortable columns."""
    print(('As a player, I can sort the magic_items table by clicking on the '
           'sortable columns'))

    magic_items_add = magic_items.MagicItemsAddModal(browser)
    magic_items_table = magic_items.MagicItemsTable(browser)
    tabs = Tabs(browser)
    tabs.inventory.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, magic_items_table.add_id)))

    magic_items_table.add.click()
    ut.select_from_autocomplete(magic_items_add,
                                'item',
                                browser,
                                has_search_term=False)
    magic_items_add.weight = 100
    magic_items_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    magic_items_table.add.click()
    ut.select_from_autocomplete(magic_items_add,
                                'item',
                                browser,
                                has_search_term=False,
                                arrow_down_count=2)
    magic_items_add.max_charges = 2
    magic_items_add.charges = 1
    magic_items_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(modal_finished_closing())

    magic_items_table.magic_item_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_down(
            magic_items_table.magic_item_header_sorting_arrow, ))
    rows = ut.get_table_row(magic_items_table, 'table', values=False)

    assert rows[0].text.strip() == 'Amulet of Health'

    magic_items_table.charges_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(magic_items_table.charges_header_sorting_arrow, ))
    rows = ut.get_table_row(magic_items_table, 'table', values=False)

    assert rows[1].text.strip() == 'N/A'

    magic_items_table.weight_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_up(magic_items_table.weight_header_sorting_arrow, ))
    rows = ut.get_table_row(magic_items_table, 'table', values=False)

    assert rows[3].text.strip() == '0 lbs.'

    magic_items_table.weight_header.click()
    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        sorting_arrow_down(magic_items_table.weight_header_sorting_arrow, ))
    rows = ut.get_table_row(magic_items_table, 'table', values=False)

    assert rows[3].text.strip() == '100 lbs.'
Example #28
0
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()

    time.sleep(.5)

    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,
        )
    )

    time.sleep(.5)

    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.'