示例#1
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()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

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

    time.sleep(.3)
    armor_table.armor_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(armor_table, 'table', values=False)
    assert rows[1].text.strip() == 'Chain mail'

    time.sleep(.3)
    armor_table.type_header.click()
    time.sleep(.3)
    rows = ut.get_table_row(armor_table, 'table', values=False)
    assert rows[2].text.strip() == 'Heavy'
示例#2
0
def test_magical_modifier(player_wizard, browser): # noqa
    """As a player, if armor is magical, a badge indicating the modifier
       is present."""
    print(('As a player, if armor is magical, a badge indicating the '
           'modifier is present.'))

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(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()
    armor_add.name = stub.name
    armor_add.magical_modifier = stub.magical_modifier

    armor_add.add.click()

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

    row = ut.get_table_row(armor_table, 'table', 1)
    actual = ' '.join([string.strip() for string in row.armor.split()])

    assert actual == '{} + {}'.format(stub.name, stub.magical_modifier)
示例#3
0
def test_preview_armor(player_wizard, browser):  # noqa
    """As a player, I can select a row in the armor table and view the item in the preview tab."""
    print(
        'As a player, I can select a row in the armor table and view the item in the preview tab'
    )

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    armor_preview = armor.ArmorPreviewModal(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

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

    assert armor_preview.name.text == 'Breastplate'
    assert armor_preview.summary.text == 'AC 14'
    assert armor_preview.weight.text == 'Weight: 20 lbs.'
    assert armor_preview.stealth.text == 'Stealth: Normal'
    assert 'metal chest piece' in armor_preview.description.text
示例#4
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()

    stub = ArmorFactory.stub()

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

    armor_table.add.click()
    armor_add.name = stub.name
    armor_add.don.click()

    armor_add.add.click()

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

    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()
示例#5
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()
示例#6
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()
示例#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'
示例#8
0
def test_autocomplete_armor(player_wizard, browser):  # noqa
    """As a player, if I start typing in the name, type and stealth field, I
       can select suggested items in the dropdown."""
    print(('As a player, if I start typing in the name, type and stealth '
           'field, I can select suggested items in the dropdown.'))

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

    assert armor_add.name.get_attribute('value').strip() == 'Breastplate'
    assert armor_add.type_.get_attribute('value').strip() == 'Light'
    assert armor_add.stealth.get_attribute('value').strip() == 'Advantage'
示例#9
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'
示例#10
0
def test_add_armor(player_wizard, browser):  # noqa
    """As a player, I can add an armor."""
    print('As a player, I can add an armor.')

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(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()
    armor_add.name = stub.name
    armor_add.type_ = stub.type_
    armor_add.magical_modifier = stub.magical_modifier
    armor_add.price = stub.price
    armor_add.currency_denomination = stub.currency_denomination
    armor_add.weight = stub.weight
    armor_add.armor_class = stub.armor_class
    armor_add.stealth = stub.stealth
    armor_add.stealth.send_keys(Keys.TAB)
    armor_add.don.click()
    armor_add.description = stub.description

    assert armor_add.name.get_attribute('value').strip() == stub.name
    assert armor_add.type_.get_attribute('value').strip() == stub.type_
    assert int(armor_add.magical_modifier.get_attribute(
        'value').strip()) == stub.magical_modifier
    assert int(armor_add.price.get_attribute('value').strip()) == stub.price

    curr_denomination = stub.currency_denomination

    assert armor_add.currency_denomination.get_attribute(
        'value').strip() == curr_denomination
    assert int(armor_add.weight.get_attribute('value').strip()) == stub.weight
    assert int(armor_add.armor_class.get_attribute(
        'value').strip()) == stub.armor_class
    assert armor_add.stealth.get_attribute('value').strip() == stub.stealth
    assert 'active' in armor_add.don.get_attribute('class').strip()
    assert armor_add.description.get_attribute(
        'value').strip() == stub.description

    armor_add.add.click()

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

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

    armor_name_label = ' '.join(
        [string.strip() for string in row.armor.split()])

    assert armor_name_label == '{} + {}'.format(stub.name,
                                                stub.magical_modifier)
    assert int(row.armor_class.strip()) == stub.armor_class
    assert row.type.strip() == stub.type_
示例#11
0
def test_add_armor_open_model_by_row(player_wizard, browser):  # noqa
    """As a player, I can click the first row in armor table to open the armor add modal."""
    print(
        'As a player, I can click the first row in armor table to open the armor add modal.'
    )

    armor_table = armor.ArmorTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

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

    assert rows[0][0].is_enabled()
    assert rows[0][0].is_displayed()
示例#12
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()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

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

    armor_edit.name = 'Edit Name'
    armor_edit.type_ = 'Edit Type'
    armor_edit.magical_modifier = 2
    armor_edit.price = 300
    armor_edit.currency_denomination = 'EP'
    armor_edit.weight = 200
    armor_edit.armor_class = 16
    armor_edit.stealth = 'Advantage\t'
    armor_edit.doff.click()
    armor_edit.description = 'Edit Description'

    assert armor_edit.name.get_attribute('value') == 'Edit Name'
    assert armor_edit.type_.get_attribute('value') == 'Edit Type'
    assert armor_edit.magical_modifier.get_attribute('value') == '2'
    assert armor_edit.price.get_attribute('value') == '300'
    assert armor_edit.currency_denomination.get_attribute('value') == 'EP'
    assert armor_edit.weight.get_attribute('value') == '200'
    assert armor_edit.armor_class.get_attribute('value') == '16'
    assert armor_edit.stealth.get_attribute('value') == 'Advantage'
    assert 'active' in armor_add.doff.get_attribute('class')
    assert armor_edit.description.get_attribute('value') == 'Edit Description'
    armor_edit.done.click()
    time.sleep(.3)
    row = ut.get_table_row(armor_table, 'table', 1)
    assert row.armor == 'Edit Name  + 2'
    assert row.armor_class == '16'
    assert row.type == 'Edit Type'
示例#13
0
def test_preview_armor(player_wizard, browser):  # noqa
    """As a player, I can select a row in the armor table and view the item
       in the preview tab."""
    print(('As a player, I can select a row in the armor table and view '
           'the item in the preview tab'))

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    armor_preview = armor.ArmorPreviewModal(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())

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

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

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element((By.ID, armor_preview.name_id),
                                         'Breastplate'))

    armor_weight = ' '.join(
        [string.strip() for string in armor_preview.weight.text.split()])
    armor_stealth = ' '.join(
        [string.strip() for string in armor_preview.stealth.text.split()])

    assert armor_preview.name.text.strip() == 'Breastplate'
    assert armor_preview.summary.text.strip() == 'AC 14'
    assert armor_weight == 'Weight: 20 lbs.'
    assert armor_stealth == 'Stealth: Normal'
    assert 'metal chest piece' in armor_preview.description.text.strip()
示例#14
0
def test_armor_total_weight(player_wizard, browser): # noqa
    """As a player, in the armor table, total weight is calculated
       correctly."""
    print(('As a player, in the armor table, total weight is calculated '
           'correctly'))

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

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

    armor_table.add.click()
    ut.select_from_autocomplete(
        armor_add,
        'name',
        browser,
        has_search_term=False
    )
    armor_add.add.click()

    WebDriverWait(browser, DEFAULT_WAIT_TIME).until(
        EC.text_to_be_present_in_element(
            (By.ID, armor_table.total_weight_id),
            '40 (lbs)'
        )
    )

    assert armor_table.total_weight.text.strip() == '40 (lbs)'
示例#15
0
def test_autocomplete_armor(player_wizard, browser):  # noqa
    """As a player, if I start typing in the name, type and stealth field, I can select suggested items in the dropdown."""
    print(
        'As a player, if I start typing in the name, type and stealth field, I can select suggested items in the dropdown.'
    )

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    ut.select_from_autocomplete(armor_add, 'type_', '', browser)
    ut.select_from_autocomplete(armor_add, 'stealth', '', browser)

    assert armor_add.name.get_attribute('value') == 'Breastplate'
    assert armor_add.type_.get_attribute('value') == 'Light'
    assert armor_add.stealth.get_attribute('value') == 'Advantage'
示例#16
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()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

    rows = ut.get_table_rows(armor_table, 'table', values=False)
    time.sleep(.3)
    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 == 'Add a new armor'
示例#17
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()

    armor_table.add.click()
    armor_add.name = 'Add Name'
    armor_add.don.click()
    time.sleep(.5)

    armor_add.add.click()
    time.sleep(.5)

    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')
示例#18
0
def test_magical_modifier(player_wizard, browser):  # noqa
    """As a player, if armor is magical, a badge indicating the modifier is present."""
    print(
        'As a player, if armor is magical, a badge indicating the modifier is present.'
    )

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    armor_table.add.click()
    armor_add.name = 'Add Name'
    armor_add.magical_modifier = 3

    armor_add.add.click()
    time.sleep(.5)

    row = ut.get_table_row(armor_table, 'table', 1)
    assert row.armor == 'Add Name  + 3'
示例#19
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()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

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

    assert row.armor.strip() == 'Breastplate'
    assert row.armor_class == '14'
    assert row.type == 'Medium'
示例#20
0
def test_armor_total_weight(player_wizard, browser):  # noqa
    """As a player, in the armor table, total weight is calculated correctly."""
    print(
        'As a player, in the armor table, total weight is calculated correctly'
    )

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

    time.sleep(.3)

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

    assert armor_table.total_weight.text == '40 (lbs)'
示例#21
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()

    armor_table.add.click()
    ut.select_from_autocomplete(armor_add, 'name', '', browser)
    armor_add.add.click()

    browser.refresh()

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

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

    row = ut.get_table_row(armor_table, 'table', values=False)
    time.sleep(.3)
    row[0].click()
    time.sleep(.3)
    armor_tabs.edit.click()

    assert armor_edit.name.get_attribute('value') == 'Breastplate'
    assert armor_edit.armor_class.get_attribute('value') == '14'
    assert armor_edit.type_.get_attribute('value') == 'Medium'
    assert armor_edit.magical_modifier.get_attribute('value') == '0'
    assert armor_edit.price.get_attribute('value') == '400'
    assert armor_edit.currency_denomination.get_attribute('value') == 'GP'
    assert armor_edit.weight.get_attribute('value') == '20'
    assert armor_edit.armor_class.get_attribute('value') == '14'
    assert armor_edit.stealth.get_attribute('value') == 'Normal'
    assert 'armor consists of' in armor_edit.description.get_attribute('value')
示例#22
0
def test_magical_modifier(player_wizard, browser):  # noqa
    """As a player, if armor is magical, a badge indicating the modifier
       is present."""
    print(('As a player, if armor is magical, a badge indicating the '
           'modifier is present.'))

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(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,
                                arrow_down_count=2,
                                has_search_term=False)

    armor_add.magical_modifier = stub.magical_modifier

    armor_add.magical_modifier.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))

    row = ut.get_table_row(armor_table, 'table', 1)
    actual = ' '.join([string.strip() for string in row.armor.split()])

    assert actual == '{} + {}'.format('Chain mail', stub.magical_modifier)
示例#23
0
def test_add_armor(player_wizard, browser):  # noqa
    """As a player, I can add an armor."""
    print('As a player, I can add an armor.')

    armor_add = armor.ArmorAddModal(browser)
    armor_table = armor.ArmorTable(browser)
    tabs = Tabs(browser)
    tabs.equipment.click()

    armor_table.add.click()
    armor_add.name = 'Add Name'
    armor_add.type_ = 'Add Type'
    armor_add.magical_modifier = 1
    armor_add.price = 200
    armor_add.currency_denomination = 'GP'
    armor_add.weight = 100
    armor_add.armor_class = 15
    armor_add.stealth = 'Disadvantage\t'
    armor_add.don.click()
    armor_add.description = 'Add Description'

    assert armor_add.name.get_attribute('value') == 'Add Name'
    assert armor_add.type_.get_attribute('value') == 'Add Type'
    assert armor_add.magical_modifier.get_attribute('value') == '1'
    assert armor_add.price.get_attribute('value') == '200'
    assert armor_add.currency_denomination.get_attribute('value') == 'GP'
    assert armor_add.weight.get_attribute('value') == '100'
    assert armor_add.armor_class.get_attribute('value') == '15'
    assert armor_add.stealth.get_attribute('value') == 'Disadvantage'
    assert 'active' in armor_add.don.get_attribute('class')
    assert armor_add.description.get_attribute('value') == 'Add Description'
    armor_add.add.click()

    row = ut.get_table_row(armor_table, 'table', 1)
    assert row.armor == 'Add Name  + 1'
    assert row.armor_class == '15'
    assert row.type == 'Add Type'
示例#24
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'
示例#25
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_