def go_to_next_day(driver, final_date):
    WebDriverWait(driver, STANDARD_TIMEOUT).until(
        ec.invisibility_of_element_located((By.CSS_SELECTOR, 'div.loader'))
    )

    for elem in driver.find_elements_by_css_selector('.date-selector i'):
        if 'right' in elem.get_attribute('class'):
            print 'Found next day!'
            elem.click()
            break
    else:
        raise ValueError('Unable to navigate to the next day')

    WebDriverWait(driver, STANDARD_TIMEOUT).until(
        ec.text_to_be_present_in_element((By.CSS_SELECTOR, '.date-selector > span'), date_to_slash_notation(final_date))
    )
def navigate_to_date(driver, date):
    print 'Looking to navigate to {}'.format(date)
    top_buttons = driver.find_elements_by_css_selector('div.stats-calendar-dropdown th button')
    assert len(top_buttons) == 3
    current_month = create_datetime_from_calendar_text(top_buttons[1].text)
    desired_month = truncate_to_month_start(date)

    while current_month != desired_month:
        top_buttons = driver.find_elements_by_css_selector('div.stats-calendar-dropdown th button')
        assert len(top_buttons) == 3
        # click on the back button if desired month is before current month else click forward
        if current_month < desired_month:
            button_to_click = top_buttons[2]
        else:
            button_to_click = top_buttons[0]

        # change the month and refresh what we see as the current month
        button_to_click.click()
        top_buttons = driver.find_elements_by_css_selector('div.stats-calendar-dropdown th button')
        assert len(top_buttons) == 3
        current_month = create_datetime_from_calendar_text(top_buttons[1].text)

    # find all day elements only for the given month
    day_links = [link for link in driver.find_elements_by_css_selector('div.stats-calendar-dropdown td button')
                 if 'muted' not in link.find_element_by_css_selector('span').get_attribute('class')]

    for day in day_links:
        if int(day.text) == date.day:
            day.click()
            break
    else:
        print 'Unable to find day!'

    WebDriverWait(driver, STANDARD_TIMEOUT).until(
        ec.text_to_be_present_in_element((By.CSS_SELECTOR, 'div.col-sm-6.col-xs-9 span'), date_to_slash_notation(date))
    )

    WebDriverWait(driver, STANDARD_TIMEOUT).until(
        ec.invisibility_of_element_located((By.CSS_SELECTOR, 'div.loader'))
    )