Ejemplo n.º 1
0
def _get_login_error(browser_helper: SeleniumHelper):
    error_items = [
        item for item in browser_helper.find_many(By.CSS_SELECTOR, "div.error")
        if item.is_displayed()
    ]
    if error_items:
        return error_items[0].text
Ejemplo n.º 2
0
def _iter_accounts(browser_helper: SeleniumHelper):
    accounts_switcher_area = browser_helper.wait_element(
        By.CSS_SELECTOR, "section.axp-account-switcher")
    accounts_switcher = accounts_switcher_area.find_element_by_tag_name(
        "button")
    browser_helper.click(accounts_switcher)

    accounts_area = browser_helper.wait_element(By.ID, "accounts")
    account_rows = accounts_area.find_elements_by_css_selector(
        "section.account-row")

    for account_row in account_rows:
        account_name = account_row.text.strip()
        # TODO make this configurable?
        if "corporate" in account_name.lower():
            continue
        account_id = re.findall(r"\(-(\d+)\)", account_name)[0]
        yield {
            "account": {
                "id": account_id,
                "name": account_name,
                "iso_currency": "GBP"
            },
            "selenium": {
                "account_element_ref": account_row
            }
        }

    browser_helper.click(accounts_switcher)
Ejemplo n.º 3
0
def _wait_accounts(browser_helper: SeleniumHelper):
    accounts_xpath = "//div[contains(@class,'card-product-')]"
    browser_helper.wait_element(By.XPATH, accounts_xpath, timeout=120)
    return browser_helper.find_many(By.XPATH, accounts_xpath)
Ejemplo n.º 4
0
def _is_logged_in(browser_helper: SeleniumHelper):
    avatar_area = browser_helper.find_maybe(By.CSS_SELECTOR,
                                            "a#nav-primary-profile")
    return avatar_area is not None
Ejemplo n.º 5
0
def _get_login_error(browser_helper: SeleniumHelper):
    error_area = browser_helper.find_maybe(By.CSS_SELECTOR,
                                           "div#error-container-wrapper")
    if error_area and error_area.is_displayed():
        return error_area.text.strip()
Ejemplo n.º 6
0
def _get_login_error(browser_helper: SeleniumHelper):
    form_error_area = browser_helper.find_many(
        By.XPATH, "//div[contains(@class, 'FormErrorWell')]")
    if form_error_area:
        return form_error_area.find_element_by_tag_name("strong").text.strip()
Ejemplo n.º 7
0
def _get_login_error(browser_helper: SeleniumHelper):
    alert_area = browser_helper.find_maybe(By.CSS_SELECTOR, "div.alert")
    if alert_area:
        return alert_area.text
Ejemplo n.º 8
0
def _get_login_error(browser_helper: SeleniumHelper):
    error_element = browser_helper.find_maybe(By.CSS_SELECTOR, "div.alert-block")
    if error_element and error_element.is_displayed():
        return error_element.text.strip()
Ejemplo n.º 9
0
def _is_logged_in(browser_helper: SeleniumHelper):
    marker = browser_helper.find_many(By.CSS_SELECTOR, "body.logged-in")
    return marker is not None
Ejemplo n.º 10
0
def _is_logged_in(browser_helper: SeleniumHelper):
    avatar_area = browser_helper.find_maybe(By.CSS_SELECTOR, "li.avatar")
    return avatar_area is not None
Ejemplo n.º 11
0
def _get_login_error(browser_helper: SeleniumHelper):
    error_area = browser_helper.find_maybe(By.ID, "error-message")
    if error_area and error_area.is_displayed():
        return error_area.text.strip()
Ejemplo n.º 12
0
def _get_login_error(browser_helper: SeleniumHelper):
    warnings = browser_helper.find_maybe(By.CSS_SELECTOR,
                                         "div.notification--warning")
    if warnings:
        return warnings.text.strip()
    return None
Ejemplo n.º 13
0
def _wait_accounts(browser_helper: SeleniumHelper):
    return browser_helper.wait_element(By.CSS_SELECTOR, "div.accounts-body")