'Helper method to upload an image file.'

def upload_file(self, filename, wait_for_upload_button=True):

    if wait_for_upload_button:
        self.wait_for_element_visibility('.u-field-upload-button', 'upload    button    is    visible')
    file_path = InstructorDashboardPage.get_asset_path(filename)
    self.browser.execute_script('$(".u-field-upload-button").css("opacity",1);')
    self.browser.execute_script('$(".upload-button-input").css("opacity",1);')
    self.wait_for_element_visibility('.upload-button-input', 'upload    button    is    visible')
    self.browser.execute_script('$(".upload-submit").show();')
    self.q(css='.upload-submit').first.click()
    self.q(css='.upload-button-input').results[0].send_keys(file_path)
    self.wait_for_ajax()
