Beispiel #1
0
def contact_test(driver):
    driver.get("http://127.0.0.1:5000/contact/")
    driver.implicitly_wait(5)  # seconds
    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title
    util.page_wait()

    email_field = driver.find_element_by_id("email")
    email_field.send_keys(util.email)

    title_field = driver.find_element_by_id("title")
    title_field.send_keys(util.title)

    contents_field = driver.find_element_by_id("contents")
    contents_field.send_keys(util.contents)

    send_feedback_btn = driver.find_element_by_class_name("send-feedback-btn")
    driver.execute_script("arguments[0].click();", send_feedback_btn)

    # Check message was recorded
    util.page_wait()
    project_dir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
    df0 = pd.read_csv(os.path.join(project_dir, "feedback.csv"))
    submitted = np.array([util.email, util.title, util.contents])
    assert (df0 == submitted).all(1).any()
def register_test(driver):
    driver.get("http://127.0.0.1:5000")
    driver.implicitly_wait(5)  # seconds
    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title

    # Navigate to sign in form
    reg_button = driver.find_element_by_class_name("signup-btn")
    driver.execute_script("arguments[0].click();", reg_button)

    # Test redirect
    util.page_wait()
    assert "http://127.0.0.1:5000/register/" == driver.current_url
    assert "already registered" not in driver.page_source

    # Fill in sign in form
    uname_field = driver.find_element_by_id("username")
    uname_field.send_keys(util.uname)
    pwd_field = driver.find_element_by_id("password")
    pwd_field.send_keys(util.pwd)
    confirm_pwd_field = driver.find_element_by_id("confirm_password")
    confirm_pwd_field.send_keys(util.pwd)

    submit = driver.find_element_by_class_name("submit-btn")
    driver.execute_script("arguments[0].click();", submit)

    # check user registered and redirected already registered
    util.page_wait()
    assert ("already registered"
            in driver.page_source) or ("http://127.0.0.1:5000/login/"
                                       == driver.current_url)
def login_test(driver):
    driver.get("http://127.0.0.1:5000")
    driver.implicitly_wait(5)  # seconds
    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title
    # Check reg form displayed
    driver.find_element_by_class_name("registration-form")
    # Navigate to log in form
    login_button = driver.find_element_by_class_name("login-btn")
    driver.execute_script("arguments[0].click();", login_button)

    # Test redirect
    util.page_wait()
    assert "http://127.0.0.1:5000/login/" == driver.current_url

    # Fill in login form
    uname_field = driver.find_element_by_id("username")
    uname_field.send_keys(util.uname)
    pwd_field = driver.find_element_by_id("password")
    pwd_field.send_keys(util.pwd)

    submit = driver.find_element_by_class_name("signin-btn")
    driver.execute_script("arguments[0].click();", submit)

    # Check log in successfull
    disabled_login_button = driver.find_element_by_class_name("greeting")

    assert "http://127.0.0.1:5000/" == driver.current_url
    assert ("Hi " + util.uname +
            "!") in disabled_login_button.get_attribute("innerHTML")

    # Test twitter feed integration
    driver.find_element_by_class_name("twitter-timeline")
Beispiel #4
0
def test_navbar_redirect(driver, navbar_item, page):
    """
    test a specific navbar link [xpath] loads page '/page/' and displays navbar
    """
    # Navigate to navbar page
    navbar_link = driver.find_element_by_class_name(navbar_item)
    driver.execute_script("arguments[0].click();", navbar_link)

    # Test about page redirect and page loaded
    util.page_wait()
    if page == "/":
        assert driver.current_url == "http://127.0.0.1:5000/"
    else:
        assert driver.current_url == ("http://127.0.0.1:5000/" + page + "/")
    # Check page has loaded properly and that navbar is displayed
    driver.find_element_by_id("navbarBasicExample")
    # Check footer with links loaded
    driver.find_element_by_class_name("footer")
    driver.find_element_by_class_name("fa-facebook")
    driver.find_element_by_class_name("fa-twitter")
def logout_test(driver):
    driver.get("http://127.0.0.1:5000")
    driver.implicitly_wait(2)  # seconds
    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title

    # Test we are logged in
    disabled_login_button = driver.find_element_by_class_name("greeting")
    assert ("Hi " + util.uname +
            "!") in disabled_login_button.get_attribute("innerHTML")

    # Click logout button
    logout_button = driver.find_element_by_class_name("logout-btn")
    driver.execute_script("arguments[0].click();", logout_button)

    # Check we have logged out and been redirected
    util.page_wait()
    driver.find_element_by_class_name("login-btn")
    assert "http://127.0.0.1:5000/" == driver.current_url
    util.page_wait()
def social_test(driver):
    driver.get("http://127.0.0.1:5000")
    driver.implicitly_wait(5)  # seconds

    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title

    fb_link = driver.find_element_by_class_name("facebook-link")
    driver.execute_script("arguments[0].click();", fb_link)
    # fb_link.click()

    # Test redirect
    util.page_wait()
    assert util.fb_url == driver.current_url

    driver.get("http://127.0.0.1:5000")
    twitter_link = driver.find_element_by_class_name("twitter-link")
    driver.execute_script("arguments[0].click();", twitter_link)
    # twitter_link.click()

    # Test redirect
    util.page_wait()
    assert util.twitter_url == driver.current_url
def dashboard_test(driver):
    tabs = [
        "allocations", "summary", "metrics", "returns", "drawdowns", "assets",
        "overfitting"
    ]
    driver.get("http://127.0.0.1:5000")
    driver.implicitly_wait(2)  # seconds

    # Make sure we're accessing the correct webpage
    assert "Thalia" in driver.title
    util.page_wait()

    # Navigate to dashboard and check navbar
    navbar_link = driver.find_element_by_class_name("navbar-dashboard")
    driver.execute_script("arguments[0].click();", navbar_link)

    util.page_wait()
    assert driver.current_url == "http://127.0.0.1:5000/dashboard/"
    driver.find_element_by_id("navbarBasicExample")

    # Check selection tab
    tab_selected_test(driver, "allocations", tabs)

    input_money = driver.find_element_by_id("input-money")
    util.input_clear(input_money)
    input_money.send_keys(util.init_balance)

    portfolio_name = driver.find_element_by_id("portfolio-name-1")
    util.input_clear(portfolio_name)
    portfolio_name.send_keys(util.p_name)

    input_contribution = driver.find_element_by_id("input-contribution-1")
    input_contribution.clear()
    input_contribution.send_keys(util.cont_amount)

    contr_freq = driver.find_element_by_xpath(
        "//input[@id='contribution-dropdown-1']")
    contr_freq.send_keys("Monthly")
    contr_freq.send_keys(Keys.RETURN)

    reb_freq = driver.find_element_by_xpath(
        "//input[@id='rebalancing-dropdown-1']")
    reb_freq.send_keys("Monthly")
    contr_freq.send_keys(Keys.RETURN)

    lazy_ports = driver.find_element_by_xpath(
        "//input[@id='lazy-portfolios-1']")
    lazy_ports.send_keys("Growth Portfolio")
    lazy_ports.send_keys(Keys.RETURN)

    # Check adding portfolios
    for i in range(1, 5):
        for j in range(1, 5):
            if j <= i:
                assert "block" == driver.find_element_by_id(
                    "portfolio-" + str(j)).value_of_css_property("display")
            else:
                assert "none" == driver.find_element_by_id(
                    "portfolio-" + str(j)).value_of_css_property("display")

        add_port = driver.find_element_by_id("add-portfolio-btn")
        add_port.click()

    submit = driver.find_element_by_id("submit-btn")
    submit.click()

    # Test tab selection
    for tab in tabs:
        tab_select = driver.find_element_by_id(tab)
        tab_select.click()
        tab_selected_test(driver, tab, tabs)