Exemplo n.º 1
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'
Exemplo n.º 2
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',
                                browser,
                                has_search_term=False,
                                search_term='b')
    magic_items_add.weight = 5
    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,
                                search_term='b')
    magic_items_add.weight = 10
    magic_items_add.add.click()

    assert magic_items_table.total_weight.text.strip() == '15 (lbs)'
Exemplo n.º 3
0
def test_autocomplete_inventory(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.'))

    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
    )

    assert inventory_add.name.get_attribute('value').strip() == 'Abacus'
Exemplo n.º 4
0
def test_inventory_total_weight(player_wizard, browser):  # noqa
    """As a player, in the inventory table, total weight is calculated
       correctly."""
    print(('As a player, in the armor table, total weight is calculated '
           'correctly'))

    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,
                                has_search_term=False)
    inventory_add.add.click()

    assert inventory_table.total_weight.text.strip() == '4 (lbs)'
Exemplo n.º 5
0
def test_armor_donned(player_wizard, browser):  # noqa
    """As a player, the checkbox appears when armor is donned."""
    print('As a player, the checkbox appears when armor is donned.')

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

    armor_add.add.click()

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

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

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

    assert 'fa fa-check' in row[0].find_element_by_tag_name(
        'span').get_attribute('class').strip()
Exemplo n.º 6
0
def test_armor_persists(player_wizard, browser):  # noqa
    """As a player, all fields for armor persist after page refresh."""
    print('As a player, all fields for armor persist after page refresh.')

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

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

    browser.refresh()

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

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

    assert row.armor.strip() == 'Breastplate'
    assert row.armor_class.strip() == '14'
    assert row.type.strip() == 'Medium'

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

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

    armor_tabs.edit.click()
    # Sometimes the done button is greyed out, and we need to click twice for some reason
    armor_tabs.edit.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.element_to_be_clickable((By.ID, armor_edit.name_id)))

    assert armor_edit.name.get_attribute('value').strip() == 'Breastplate'
    assert armor_edit.armor_class.get_attribute('value').strip() == '14'
    assert armor_edit.type_.get_attribute('value').strip() == 'Medium'
    assert armor_edit.magical_modifier.get_attribute('value').strip() == '0'
    assert armor_edit.price.get_attribute('value').strip() == '400'
    assert armor_edit.currency_denomination.get_attribute(
        'value').strip() == 'GP'
    assert armor_edit.weight.get_attribute('value').strip() == '20'
    assert armor_edit.armor_class.get_attribute('value').strip() == '14'
    assert armor_edit.stealth.get_attribute('value').strip() == 'Normal'
    assert 'armor consists of' in armor_edit.description.get_attribute(
        'value').strip()
Exemplo n.º 7
0
def test_armor_ogl_pre_pop(player_wizard, browser):  # noqa
    """As a player, if I select from armor name field, OGL data auto-completes
       and the remaining fields pre-populate."""
    print(('As a player, if I select from armor name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

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

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

    assert row.armor.strip() == 'Breastplate'
    assert row.armor_class.strip() == '14'
    assert row.type.strip() == 'Medium'
Exemplo n.º 8
0
def test_delete_magic_items(player_wizard, browser): # noqa
    """As a player, I can delete an item in my magic_items."""
    print('As a player, I can delete an item to my magic_items.')

    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',
        browser,
        has_search_term=False
    )
    magic_items_add.add.click()

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

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

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

    rows[0][5].find_element_by_tag_name('a').click()

    time.sleep(.5)

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

    assert rows[0][0].text.strip() == 'Add a new magic item'
Exemplo n.º 9
0
def test_race_autocomplete(player_wizard, browser): # noqa
    """As a player, if I start typing in the race field, OGL data auto-completes."""
    print('As a player, if I start typing in the race field, OGL data auto-completes.')

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

    ut.select_from_autocomplete(
        profile,
        'race',
        browser,
        has_search_term=False
    )

    assert profile.race.get_attribute('value').strip() == 'Dwarf'

    profile.race.clear()

    ut.select_from_autocomplete(
        profile,
        'race',
        browser,
        has_search_term=True,
        search_term='c'
    )

    assert profile.race.get_attribute('value').strip() == 'Rock Gnome'
Exemplo n.º 10
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.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][2].click()

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

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

    assert rows[0][0].text.strip() == 'Add a new Feature'
Exemplo n.º 11
0
def test_inventory_ogl_pre_pop(player_wizard, browser):  # noqa
    """As a player, if I select from inventory name field, OGL data
       auto-completes and the remaining fields pre-populate."""
    print(('As a player, if I select from inventory name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

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

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

    assert row.item.strip() == 'Abacus'
    assert row.weight.strip() == '2 lbs.'
    assert row.quantity.strip() == '1'
    assert row.cost.strip() == '2 GP'
    assert row.description.strip() == ''
Exemplo n.º 12
0
def test_weapon_ogl_pre_pop(player_wizard, browser): # noqa
    """As a player, if I select from weapon name field, OGL data auto-completes
       and the remaining fields pre-populate."""
    print(('As a player, if I select from weapon name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

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

    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'
Exemplo n.º 13
0
def test_feature_ogl_pre_pop(player_wizard, browser):  # noqa
    """As a player, if I select from feature name field, OGL data
       auto-completes and the remaining fields pre-populate."""
    print(('As a player, if I select from feature name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

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

    feature.add.click()

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

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

    assert row.class_.strip() == 'Barbarian'
    assert 'Rage' in row.feature.strip()
Exemplo n.º 14
0
def test_proficiency_ogl_pre_pop(player_wizard, browser):  # noqa
    """As a player, if I select from proficiency name field, OGL data
       auto-completes and the remaining fields pre-populate."""
    print(('As a player, if I select from proficiency name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

    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)

    proficiency_add.name.send_keys(Keys.TAB)

    proficiency_add.add.click()

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

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

    assert row.type.strip() == 'Languages'
    assert row.proficiency.strip() == 'Abyssal'
Exemplo n.º 15
0
def test_trait_ogl_pre_pop(player_wizard, browser):  # noqa
    """As a player, if I select from trait name field, OGL data auto-completes
       and the remaining fields pre-populate."""
    print(('As a player, if I select from trait name field, OGL data '
           'auto-completes and the remaining fields pre-populate.'))

    trait = traits.TraitAddModal(browser)
    traits_table = traits.TraitsTable(browser)
    tabs = Tabs(browser)
    tabs.skills.click()

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

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

    assert row.race.strip() == 'Dragonborn'
    assert row.trait.strip() == 'Ability Score Increase'
Exemplo n.º 16
0
def test_delete_trait(player_wizard, browser):  # noqa
    """As a player, I can delete a trait."""
    print('As a player, I can delete a trait.')

    trait = traits.TraitAddModal(browser)
    traits_table = traits.TraitsTable(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][2].find_element_by_tag_name('a').click()

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

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

    assert rows[0][0].text.strip() == 'Add a new Trait'
Exemplo n.º 17
0
def test_delete_armor(player_wizard, browser): # noqa
    """As a player, I can delete an armor."""
    print('As a player, I can delete an armor.')

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

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

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

    rows[0][4].find_element_by_tag_name('a').click()
    rows = ut.get_table_rows(armor_table, 'table', values=False)

    assert rows[0][0].text.strip() == 'Add a new armor'
Exemplo n.º 18
0
def test_delete_proficiency(player_wizard, browser):  # noqa
    """As a player, I can delete a proficiency."""
    print('As a player, I can delete a proficiency.')

    proficiency_add = proficiency.ProficiencyAddModal(browser)
    proficiency_table = proficiency.ProficiencyTable(browser)
    tabs = Tabs(browser)
    tabs.skills.click()

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

    proficiency_table.add.click()
    ut.select_from_autocomplete(proficiency_add,
                                'name',
                                browser,
                                has_search_term=False)
    proficiency_add.add.click()

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

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

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

    assert rows[0][0].text.strip() == 'Add a new Proficiency'
Exemplo n.º 19
0
def test_background_autocomplete(player_wizard, browser): # noqa
    """As a player, if I start typing in the background field, OGL data auto-completes."""
    print('As a player, if I start typing in the background field, OGL data auto-completes.')

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

    ut.select_from_autocomplete(
        profile,
        'background',
        browser,
        has_search_term=False
    )

    assert profile.background.get_attribute('value').strip() == 'Acolyte'

    profile.background.clear()

    ut.select_from_autocomplete(
        profile,
        'background',
        browser,
        has_search_term=True,
        search_term='f'
    )

    assert profile.background.get_attribute('value').strip() == 'Folk Hero'
Exemplo n.º 20
0
def test_class_autocomplete(player_wizard, browser): # noqa
    """As a player, if I start typing in the class field, OGL data auto-completes."""
    print('As a player, if I start typing in the class field, OGL data auto-completes.')

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

    ut.select_from_autocomplete(
        profile,
        'class_',
        browser,
        has_search_term=False
    )

    assert profile.class_.get_attribute('value').strip() == 'Barbarian'

    profile.class_.clear()

    ut.select_from_autocomplete(
        profile,
        'class_',
        browser,
        has_search_term=True,
        search_term='c'
    )

    assert profile.class_.get_attribute('value').strip() == 'Cleric'
Exemplo n.º 21
0
def test_delete_spells(player_wizard, browser):  # noqa
    """As a player, I can delete a spells."""
    print('As a player, I can delete 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()
    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][7].find_element_by_tag_name('a').click()

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

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

    assert rows[0][0].text.strip() == 'Add a new spell'
Exemplo n.º 22
0
def test_alignment_autocomplete(player_wizard, browser): # noqa
    """As a player, if I start typing in the alignment field, OGL data auto-completes."""
    print('As a player, if I start typing in the alignment field, OGL data auto-completes.')

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

    ut.select_from_autocomplete(
        profile,
        'alignment',
        browser,
        has_search_term=False
    )

    assert profile.alignment.get_attribute('value').strip() == 'Lawful good'

    profile.alignment.clear()

    ut.select_from_autocomplete(
        profile,
        'alignment',
        browser,
        has_search_term=True,
        search_term='c'
    )

    assert profile.alignment.get_attribute('value').strip() == 'Chaotic good'
Exemplo n.º 23
0
def test_preview_magic_items(player_wizard, browser): # noqa
    """As a player, I can select a row in the magic_items table and view the
       item in the preview tab."""
    print(('As a player, I can select a row in the magic_items table and view '
           ' the item in the preview tab'))

    magic_items_add = magic_items.MagicItemsAddModal(browser)
    magic_items_table = magic_items.MagicItemsTable(browser)
    magic_items_preview = magic_items.MagicItemsPreviewModal(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()
    )

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

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

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element(
            (By.ID, magic_items_preview.item_id), 'Adamantine Armor'
        )
    )

    preview_type_ = magic_items_preview.type_.text.split()
    magic_items_type = ' '.join([string.strip() for string in preview_type_])
    magic_items_max_charges = ' '.join(
        [
            string.strip()
            for string in magic_items_preview.max_charges.text.split()
        ]
    )
    magic_items_weight = ' '.join(
        [
            string.strip()
            for string in magic_items_preview.weight.text.split()
        ]
    )

    assert magic_items_preview.item.text.strip() == 'Adamantine Armor'
    assert magic_items_preview.rarity.text.strip() == 'Uncommon'
    assert magic_items_type == 'Type: Armor (medium or heavy but not hide)'
    assert magic_items_max_charges == 'Max Charges: 0'
    assert magic_items_weight == 'Weight: 0 lbs.'
    assert 'reinforced with adamantine' in magic_items_preview.description.text.strip()
Exemplo n.º 24
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.add.click()

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

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

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

    trait_tabs.edit.click()

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

    trait_edit.name = 'Edited Name'
    trait_edit.race = 'Edited Race'
    trait_edit.description = 'Edited Description'
    trait_edit.tracked.click()
    trait_edit.max_ = 4
    trait_edit.short_rest.click()

    assert trait_edit.name.get_attribute('value').strip() == 'Edited Name'
    assert trait_edit.race.get_attribute('value').strip() == 'Edited Race'
    assert trait_edit.description.get_attribute(
        'value').strip() == 'Edited Description'
    assert trait_edit.max_.get_attribute('value').strip() == '4'
    assert 'active' in trait_edit.short_rest.get_attribute('class').strip()

    trait_edit.done.click()

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

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

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        table_cell_updated(traits_table, 'trait', 'Edited Name', 'table', 1))

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

    assert row.trait.strip() == 'Edited Name'
    assert row.race.strip() == 'Edited Race'
Exemplo n.º 25
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()

    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, ))
    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.'
Exemplo n.º 26
0
def test_inventory_persists(player_wizard, browser): # noqa
    """As a player, all fields for inventory persist after page refresh."""
    print('As a player, all fields for inventory persist after page refresh.')

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

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

    browser.refresh()

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

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

    assert row.item.strip() == 'Abacus'
    assert row.weight.strip() == '2 lbs.'
    assert row.quantity.strip() == '1'
    assert row.cost.strip() == '2 GP'
    assert row.description.strip() == ''

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

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

    inventory_tabs.edit.click()

    assert inventory_edit.name.get_attribute('value').strip() == 'Abacus'
    assert inventory_edit.weight.get_attribute('value').strip() == '2'
    assert inventory_edit.quantity.get_attribute('value').strip() == '1'
    assert inventory_edit.cost.get_attribute('value').strip() == '2'
    assert inventory_edit.currency_denomination.get_attribute('value').strip() == 'GP'
    assert inventory_edit.description.get_attribute('value').strip() == ''
Exemplo n.º 27
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())

    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())
    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'
Exemplo n.º 28
0
def test_edit_proficiency(player_wizard, browser):  # noqa
    """As a player, I can edit a proficiency."""
    print('As a player, I can edit a proficiency.')

    proficiency_add = proficiency.ProficiencyAddModal(browser)
    proficiency_edit = proficiency.ProficiencyEditModal(browser)
    proficiency_table = proficiency.ProficiencyTable(browser)
    proficiency_tabs = proficiency.ProficiencyModalTabs(browser)
    tabs = Tabs(browser)
    tabs.skills.click()

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

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

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

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

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

    proficiency_tabs.edit.click()

    proficiency_edit.name = 'Edited Name'
    proficiency_edit.type_ = 'Edited Type'
    proficiency_edit.description = 'Edited Description'

    assert proficiency_edit.name.get_attribute(
        'value').strip() == 'Edited Name'
    assert proficiency_edit.type_.get_attribute(
        'value').strip() == 'Edited Type'
    assert proficiency_edit.description.get_attribute(
        'value').strip() == 'Edited Description'

    proficiency_edit.done.click()

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

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

    assert row.proficiency.strip() == 'Edited Name'
    assert row.type.strip() == 'Edited Type'
Exemplo n.º 29
0
def test_edit_feat(player_wizard, browser):  # noqa
    """As a player, I can edit a feat."""
    print('As a player, I can edit a feat.')

    feat = feats.FeatAddModal(browser)
    feat_edit = feats.FeatEditModal(browser)
    feats_table = feats.FeatsTable(browser)
    feat_tabs = feats.FeatModalTabs(browser)
    tabs = Tabs(browser)
    tabs.skills.click()

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

    feats_table.add.click()

    ut.select_from_autocomplete(feat, 'name', browser, has_search_term=False)

    feat.name.send_keys(Keys.TAB)

    feat.add.click()

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

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

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

    feat_tabs.edit.click()
    feat_tabs.edit.click()

    feat_edit.name = 'Edited Name'
    feat_edit.description = 'Edited Description'
    feat_edit.tracked.click()
    feat_edit.max_ = 4
    feat_edit.short_rest.click()

    assert feat_edit.name.get_attribute('value').strip() == 'Edited Name'
    assert feat_edit.description.get_attribute(
        'value').strip() == 'Edited Description'
    assert feat_edit.max_.get_attribute('value').strip() == '4'
    assert 'active' in feat_edit.short_rest.get_attribute('class').strip()

    feat_edit.done.click()

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

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        table_cell_updated(feats_table, 'feat', 'Edited Name', 'table', 1))

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

    assert row.feat.strip() == 'Edited Name'
Exemplo n.º 30
0
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)'