Esempio n. 1
0
def i_visit_the_studio_homepage(_step):
    # To make this go to port 8001, put
    # LETTUCE_SERVER_PORT = 8001
    # in your settings.py file.
    world.visit('/')
    signin_css = 'a.action-signin'
    assert world.is_css_present(signin_css)
Esempio n. 2
0
def go_to_section(section_name):
    # section name should be one of
    # course_info, membership, student_admin, data_download, analytics, send_email
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('div.beta-button-wrapper>a')
    world.css_click('a[data-section="{0}"]'.format(section_name))
Esempio n. 3
0
def initial_setup(server):
    """
    Launch the browser once before executing the tests.
    """
    world.absorb(settings.LETTUCE_SELENIUM_CLIENT, 'LETTUCE_SELENIUM_CLIENT')

    if world.LETTUCE_SELENIUM_CLIENT == 'local':
        browser_driver = getattr(settings, 'LETTUCE_BROWSER', 'chrome')

        # There is an issue with ChromeDriver2 r195627 on Ubuntu
        # in which we sometimes get an invalid browser session.
        # This is a work-around to ensure that we get a valid session.
        success = False
        num_attempts = 0
        while (not success) and num_attempts < MAX_VALID_BROWSER_ATTEMPTS:
            world.browser = Browser(browser_driver)

            # Try to visit the main page
            # If the browser session is invalid, this will
            # raise a WebDriverException
            try:
                world.visit('/')

            except WebDriverException:
                world.browser.quit()
                num_attempts += 1

            else:
                success = True

        # If we were unable to get a valid session within the limit of attempts,
        # then we cannot run the tests.
        if not success:
            raise IOError("Could not acquire valid {driver} browser session.".format(driver=browser_driver))

        world.absorb(0, 'IMPLICIT_WAIT')
        world.browser.driver.set_window_size(1280, 1024)

    elif world.LETTUCE_SELENIUM_CLIENT == 'saucelabs':
        config = get_saucelabs_username_and_key()
        world.browser = Browser(
            'remote',
            url="http://{}:{}@ondemand.saucelabs.com:80/wd/hub".format(config['username'], config['access-key']),
            **make_saucelabs_desired_capabilities()
        )
        world.absorb(30, 'IMPLICIT_WAIT')

    elif world.LETTUCE_SELENIUM_CLIENT == 'grid':
        world.browser = Browser(
            'remote',
            url=settings.SELENIUM_GRID.get('URL'),
            browser=settings.SELENIUM_GRID.get('BROWSER'),
        )
        world.absorb(30, 'IMPLICIT_WAIT')

    else:
        raise Exception("Unknown selenium client '{}'".format(world.LETTUCE_SELENIUM_CLIENT))

    world.browser.driver.implicitly_wait(world.IMPLICIT_WAIT)
    world.absorb(world.browser.driver.session_id, 'jobid')
Esempio n. 4
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******'):

    world.log_in(username=uname, password=password, email=email, name='Robot Studio')
    # Navigate to the studio dashboard
    world.visit('/')
def i_created_unit_with_advanced_module(step, advanced_module):
    world.create_course_with_unit()

    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module))
    world.visit(url)
    world.wait_for_xmodule()
def i_created_unit_with_advanced_module(step, advanced_module):
    step.given('I am in Studio editing a new unit')

    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, ADVANCED_MODULES_KEY, '["{}"]'.format(advanced_module))
    world.visit(url)
    world.wait_for_xmodule()
Esempio n. 7
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******',
        name='Robot Studio'):

    world.log_in(username=uname, password=password, email=email, name=name)
    # Navigate to the studio dashboard
    world.visit('/')
    world.wait_for(lambda _driver: uname in world.css_find('h2.title')[0].text)
Esempio n. 8
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******',
        name='Robot Studio'):

    world.log_in(username=uname, password=password, email=email, name=name)
    # Navigate to the studio dashboard
    world.visit('/')
    assert_in(uname, world.css_text('span.account-username', timeout=10))
Esempio n. 9
0
def main_course_page(step):
    course_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_')
    main_page_link = '/course/{org}.{number}.{name}/branch/draft/block/{name}'.format(
        org=world.scenario_dict['COURSE'].org,
        number=world.scenario_dict['COURSE'].number,
        name=course_name
    )

    world.visit(main_page_link)
    assert_in('Course Outline', world.css_text('h1.page-header'))
Esempio n. 10
0
def log_in(username='******', password='******', email='*****@*****.**', name='Robot'):
    """
    Use the auto_auth feature to programmatically log the user in
    """
    url = '/auto_auth?username=%s&password=%s&name=%s&email=%s' % (username,
          password, name, email)
    world.visit(url)

    # Save the user info in the world scenario_dict for use in the tests
    user = User.objects.get(username=username)
    world.scenario_dict['USER'] = user
Esempio n. 11
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)
Esempio n. 12
0
def i_created_a_video_component(step):
    step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    step.given('I have uploaded subtitles')

    # Return to the video
    world.visit(video_url)
Esempio n. 13
0
def main_course_page(step):
    course_name = world.scenario_dict['COURSE'].display_name.replace(' ', '_')
    course_key = SlashSeparatedCourseKey(
        world.scenario_dict['COURSE'].org,
        world.scenario_dict['COURSE'].number,
        course_name
    )
    main_page_link = reverse_course_url('course_handler', course_key)

    world.visit(main_page_link)
    assert_in('Course Outline', world.css_text('h1.page-header'))
Esempio n. 14
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******',
        name='Robot Studio'):

    world.log_in(username=uname, password=password, email=email, name=name)
    # Navigate to the studio dashboard
    world.visit('/')

    assert uname in world.css_text('h2.title', max_attempts=15)
Esempio n. 15
0
def log_in(username='******', password='******', email='*****@*****.**', name="Robot"):
    """
    Use the auto_auth feature to programmatically log the user in
    """
    url = '/auto_auth'
    params = {'username': username, 'password': password, 'email': email, 'full_name': name}
    url += "?" + urllib.urlencode(params)
    world.visit(url)

    # Save the user info in the world scenario_dict for use in the tests
    user = get_user_model().objects.get(username=username)
    world.scenario_dict['USER'] = user
def log_in(username="******", password="******", email="*****@*****.**", name="Robot"):
    """
    Use the auto_auth feature to programmatically log the user in
    """
    url = "/auto_auth"
    params = {"username": username, "password": password, "email": email, "full_name": name}
    url += "?" + urllib.urlencode(params)
    world.visit(url)

    # Save the user info in the world scenario_dict for use in the tests
    user = User.objects.get(username=username)
    world.scenario_dict["USER"] = user
Esempio n. 17
0
def view_asset(_step, file_name, status):
    url = '/c4x/MITx/999/asset/' + file_name
    if status == 'viewable':
        world.visit(url)
        _verify_body_text()
    else:
        error_thrown = False
        try:
            world.visit(url)
        except Exception as e:
            assert e.status_code == 403
            error_thrown = True
        assert error_thrown
Esempio n. 18
0
def i_select_advanced_settings(step):

    world.click_course_settings()

    # The click handlers are set up so that if you click <body>
    # the menu disappears.  This means that if we're even a *little*
    # bit off on the last item ('Advanced Settings'), the menu
    # will close and the test will fail.
    # For this reason, we retrieve the link and visit it directly
    # This is what the browser *should* be doing, since it's just a native
    # link with no JavaScript involved.
    link_css = 'li.nav-course-settings-advanced a'
    world.wait_for_visible(link_css)
    link = world.css_find(link_css).first['href']
    world.visit(link)
Esempio n. 19
0
def other_user_login(step, name):
    step.given('I log out')
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(name + '@edx.org')
        login_form.find_by_name('password').fill("test")
        login_form.find_by_name('submit').click()
    world.retry_on_exception(fill_login_form)
    assert world.is_css_present('.new-course-button')
    world.scenario_dict['USER'] = get_user(name + '@edx.org')
Esempio n. 20
0
def create_a_course():
    course = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
    world.scenario_dict['COURSE'] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user('*****@*****.**')

    add_course_author(user, course)

    # Navigate to the studio dashboard
    world.visit('/')
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert world.is_css_present(course_title_css)
Esempio n. 21
0
def other_user_login(_step, name):
    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(name + EMAIL_EXTENSION)
        login_form.find_by_name('password').fill(PASSWORD)
        login_form.find_by_name('submit').click()
    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present('.new-course-button'))
    world.scenario_dict['USER'] = get_user_by_email(name + EMAIL_EXTENSION)
Esempio n. 22
0
def create_a_course():
    course = world.CourseFactory.create(org="MITx", course="999", display_name="Robot Super Course")
    world.scenario_dict["COURSE"] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user("*****@*****.**")

    add_course_author(user, course)

    # Navigate to the studio dashboard
    world.visit("/")
    course_link_css = "a.course-link"
    world.css_click(course_link_css)
    course_title_css = "span.course-title"
    assert_true(world.is_css_present(course_title_css))
Esempio n. 23
0
def initial_setup(server):
    """
    Launch the browser once before executing the tests.
    """
    world.absorb(settings.SAUCE.get("SAUCE_ENABLED"), "SAUCE_ENABLED")

    if not world.SAUCE_ENABLED:
        browser_driver = getattr(settings, "LETTUCE_BROWSER", "chrome")

        # There is an issue with ChromeDriver2 r195627 on Ubuntu
        # in which we sometimes get an invalid browser session.
        # This is a work-around to ensure that we get a valid session.
        success = False
        num_attempts = 0
        while (not success) and num_attempts < MAX_VALID_BROWSER_ATTEMPTS:
            world.browser = Browser(browser_driver)

            # Try to visit the main page
            # If the browser session is invalid, this will
            # raise a WebDriverException
            try:
                world.visit("/")

            except WebDriverException:
                world.browser.quit()
                num_attempts += 1

            else:
                success = True

        # If we were unable to get a valid session within the limit of attempts,
        # then we cannot run the tests.
        if not success:
            raise IOError("Could not acquire valid {driver} browser session.".format(driver=browser_driver))

        world.browser.driver.set_window_size(1280, 1024)

    else:
        config = get_username_and_key()
        world.browser = Browser(
            "remote",
            url="http://{}:{}@ondemand.saucelabs.com:80/wd/hub".format(config["username"], config["access-key"]),
            **make_desired_capabilities()
        )
        world.browser.driver.implicitly_wait(30)

    world.absorb(world.browser.driver.session_id, "jobid")
Esempio n. 24
0
def other_user_login(step, name):
    step.given("I log out")
    world.visit("/")

    signin_css = "a.action-signin"
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css("form#login_form")
        login_form.find_by_name("email").fill(name + "@edx.org")
        login_form.find_by_name("password").fill("test")
        login_form.find_by_name("submit").click()

    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present(".new-course-button"))
    world.scenario_dict["USER"] = get_user(name + "@edx.org")
Esempio n. 25
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()
    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
Esempio n. 26
0
def when_i_send_an_email(step, recipient):

    # Check that the recipient is valid
    assert_in(
        recipient, SEND_TO_OPTIONS,
        msg="Invalid recipient: {}".format(recipient)
    )

    # Clear the queue of existing emails
    while not mail.queue.empty():  # pylint: disable=E1101
        mail.queue.get()  # pylint: disable=E1101

    # Because we flush the database before each run,
    # we need to ensure that the email template fixture
    # is re-loaded into the database
    call_command('loaddata', 'course_email_template.json')

    # Go to the email section of the instructor dash
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('div.beta-button-wrapper>a')
    world.css_click('a[data-section="send_email"]')

    # Select the recipient
    world.select_option('send_to', SEND_TO_OPTIONS[recipient])

    # Enter subject and message
    world.css_fill('input#id_subject', 'Hello')

    with world.browser.get_iframe('mce_0_ifr') as iframe:
        editor = iframe.find_by_id('tinymce')[0]
        editor.fill('test message')

    # Click send
    world.css_click('input[name="send"]')

    # Confirm the alert
    world.browser.get_alert().accept()

    # Expect to see a message that the email was sent
    expected_msg = "Your email was successfully queued for sending."
    world.wait_for_visible('#request-response')
    assert_in(
        expected_msg, world.css_text('#request-response'),
        msg="Could not find email success message."
    )
Esempio n. 27
0
def log_into_studio(uname="robot", email="*****@*****.**", password="******"):

    world.browser.cookies.delete()
    world.visit("/")

    signin_css = "a.action-signin"
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css("form#login_form")
        login_form.find_by_name("email").fill(email)
        login_form.find_by_name("password").fill(password)
        login_form.find_by_name("submit").click()

    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present(".new-course-button"))
    world.scenario_dict["USER"] = get_user_by_email(email)
Esempio n. 28
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******'):

    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    login_form = world.browser.find_by_css('form#login_form')
    login_form.find_by_name('email').fill(email)
    login_form.find_by_name('password').fill(password)
    login_form.find_by_name('submit').click()

    assert_true(world.is_css_present('.new-course-button'))
Esempio n. 29
0
def log_into_studio(uname='robot',
                    email='*****@*****.**',
                    password='******'):

    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(email)
        login_form.find_by_name('password').fill(password)
        login_form.find_by_name('submit').click()

    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present('.new-course-button'))
    world.scenario_dict['USER'] = get_user_by_email(email)
Esempio n. 30
0
def log_into_studio(
        uname='robot',
        email='*****@*****.**',
        password='******'):

    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    def fill_login_form():
        login_form = world.browser.find_by_css('form#login_form')
        login_form.find_by_name('email').fill(email)
        login_form.find_by_name('password').fill(password)
        login_form.find_by_name('submit').click()
    world.retry_on_exception(fill_login_form)
    assert_true(world.is_css_present('.new-course-button'))
    world.scenario_dict['USER'] = get_user_by_email(email)
Esempio n. 31
0
def log_into_studio(uname='robot',
                    email='*****@*****.**',
                    password='******',
                    is_staff=False):

    create_studio_user(uname=uname, email=email, is_staff=is_staff)

    world.browser.cookies.delete()
    world.visit('/')

    signin_css = 'a.action-signin'
    world.is_css_present(signin_css)
    world.css_click(signin_css)

    login_form = world.browser.find_by_css('form#login_form')
    login_form.find_by_name('email').fill(email)
    login_form.find_by_name('password').fill(password)
    login_form.find_by_name('submit').click()

    assert_true(world.is_css_present('.new-course-button'))
Esempio n. 32
0
def log_in(username='******',
           password='******',
           email='*****@*****.**',
           name="Robot"):
    """
    Use the auto_auth feature to programmatically log the user in
    """
    url = '/auto_auth'
    params = {
        'username': username,
        'password': password,
        'email': email,
        'full_name': name
    }
    url += "?" + urllib.urlencode(params)
    world.visit(url)

    # Save the user info in the world scenario_dict for use in the tests
    user = User.objects.get(username=username)
    world.scenario_dict['USER'] = user
Esempio n. 33
0
def when_i_send_an_email(step, recipient):

    # Check that the recipient is valid
    assert_in(recipient,
              SEND_TO_OPTIONS,
              msg="Invalid recipient: {}".format(recipient))

    # Clear the queue of existing emails
    while not mail.queue.empty():  # pylint: disable=E1101
        mail.queue.get()  # pylint: disable=E1101

    # Because we flush the database before each run,
    # we need to ensure that the email template fixture
    # is re-loaded into the database
    call_command('loaddata', 'course_email_template.json')

    # Go to the email section of the instructor dash
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('div.beta-button-wrapper>a')
    world.css_click('a[data-section="send_email"]')

    # Select the recipient
    world.select_option('send_to', SEND_TO_OPTIONS[recipient])

    # Enter subject and message
    world.css_fill('input#id_subject', 'Hello')

    with world.browser.get_iframe('mce_0_ifr') as iframe:
        editor = iframe.find_by_id('tinymce')[0]
        editor.fill('test message')

    # Click send
    world.css_click('input[name="send"]', dismiss_alert=True)

    # Expect to see a message that the email was sent
    expected_msg = "Your email was successfully queued for sending."
    world.wait_for_visible('#request-response')
    assert_in(expected_msg,
              world.css_text('#request-response'),
              msg="Could not find email success message.")
Esempio n. 34
0
def create_a_course():
    course = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
    world.scenario_dict['COURSE'] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user_by_email('*****@*****.**')

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio
    for role in ("staff", "instructor"):
        groupname = get_course_groupname_for_role(course.location, role)
        group, __ = Group.objects.get_or_create(name=groupname)
        user.groups.add(group)
    user.save()

    # Navigate to the studio dashboard
    world.visit('/')
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Esempio n. 35
0
def create_a_course():
    course = world.CourseFactory.create(org='MITx', course='999', display_name='Robot Super Course')
    world.scenario_dict['COURSE'] = course

    user = world.scenario_dict.get("USER")
    if not user:
        user = get_user_by_email('*****@*****.**')

    # Add the user to the instructor group of the course
    # so they will have the permissions to see it in studio
    for role in ("staff", "instructor"):
        groupname = get_course_groupname_for_role(course.location, role)
        group, __ = Group.objects.get_or_create(name=groupname)
        user.groups.add(group)
    user.save()

    # Navigate to the studio dashboard
    world.visit('/')
    course_link_css = 'a.course-link'
    world.css_click(course_link_css)
    course_title_css = 'span.course-title'
    assert_true(world.is_css_present(course_title_css))
Esempio n. 36
0
def initial_setup(server):
    """
    Launch the browser once before executing the tests.
    """
    browser_driver = getattr(settings, 'LETTUCE_BROWSER', 'chrome')

    # There is an issue with ChromeDriver2 r195627 on Ubuntu
    # in which we sometimes get an invalid browser session.
    # This is a work-around to ensure that we get a valid session.
    success = False
    num_attempts = 0
    while (not success) and num_attempts < MAX_VALID_BROWSER_ATTEMPTS:

        # Get a browser session
        world.browser = Browser(browser_driver)

        # Try to visit the main page
        # If the browser session is invalid, this will
        # raise a WebDriverException
        try:
            world.visit('/')

        except WebDriverException:
            world.browser.quit()
            num_attempts += 1

        else:
            success = True

    # If we were unable to get a valid session within the limit of attempts,
    # then we cannot run the tests.
    if not success:
        raise IOError(
            "Could not acquire valid {driver} browser session.".format(
                driver=browser_driver))

    # Set the browser size to 1280x1024
    world.browser.driver.set_window_size(1280, 1024)
def i_select_advanced_settings(step):

    world.wait_for_js_to_load()  # pylint: disable=no-member
    world.wait_for_js_variable_truthy('window.studioNavMenuActive')  # pylint: disable=no-member

    for _ in range(5):
        world.click_course_settings()  # pylint: disable=no-member

        # The click handlers are set up so that if you click <body>
        # the menu disappears.  This means that if we're even a *little*
        # bit off on the last item ('Advanced Settings'), the menu
        # will close and the test will fail.
        # For this reason, we retrieve the link and visit it directly
        # This is what the browser *should* be doing, since it's just a native
        # link with no JavaScript involved.
        link_css = 'li.nav-course-settings-advanced a'
        try:
            world.wait_for_visible(link_css)  # pylint: disable=no-member
            break
        except AssertionError:
            continue

    link = world.css_find(link_css).first['href']
    world.visit(link)
Esempio n. 38
0
def i_created_a_video_with_subs_with_name(_step, sub_id):
    _step.given('I have created a Video component')

    # Store the current URL so we can return here
    video_url = world.browser.url

    # Upload subtitles for the video using the upload interface
    _step.given('I have uploaded subtitles "{}"'.format(sub_id))

    # Return to the video
    world.visit(video_url)

    world.wait_for_xmodule()

    # update .sub filed with proper subs name (which mimics real Studio/XML behavior)
    # this is needed only for that videos which are created in acceptance tests.
    _step.given('I edit the component')
    world.wait_for_ajax_complete()
    _step.given('I save changes')

    world.disable_jquery_animations()

    world.wait_for_present('.is-initialized')
    world.wait_for_invisible(SELECTORS['spinner'])
def i_visit_the_course_info_url(step):
    world.visit('/courses/MITx/6.002x/2012_Fall/courseware')
Esempio n. 40
0
def i_am_on_the_courses_page(step):
    world.visit('/courses')
    assert world.is_css_present('section.courses')
Esempio n. 41
0
def and_i_return_to_the_courseware(step):
    world.visit('/')
    world.click_link("View Course")
    world.click_link("Courseware")
Esempio n. 42
0
def i_visit_the_homepage(step):
    world.visit('/')
    assert world.is_css_present('header.global')
Esempio n. 43
0
def i_visit_the_dashboard(step):
    world.visit('/dashboard')
    assert world.is_css_present('section.container.dashboard')
Esempio n. 44
0
def main_course_page(step):
    main_page_link = reverse_course_url('course_handler',
                                        world.scenario_dict['COURSE'].id)

    world.visit(main_page_link)
    assert_in('Course Outline', world.css_text('h1.page-header'))
Esempio n. 45
0
def create_user_and_visit_course():
    # TODO:  this needs to update our mocked storage
    world.register_by_course_key(world.scenario_dict['COURSE'].id)
    world.log_in()
    world.visit(u'/courses/{}/courseware/'.format(
        world.scenario_dict['COURSE'].id))
Esempio n. 46
0
def leave_the_flow_and_return(step):
    world.visit('verify_student/verified/edx/999/Certificates/')
Esempio n. 47
0
def create_user_and_visit_course():
    world.register_by_course_id('edx/999/Test_Course')
    world.log_in()
    world.visit('/courses/edx/999/Test_Course/courseware/')
Esempio n. 48
0
def go_to_section(section_name):
    # section name should be one of
    # course_info, membership, student_admin, data_download, analytics, send_email
    world.visit(u'/courses/{}'.format(world.course_key))
    world.css_click(u'a[href="/courses/{}/instructor"]'.format(world.course_key))
    world.css_click('[data-section="{0}"]'.format(section_name))
Esempio n. 49
0
def create_user_and_visit_course():
    world.register_by_course_key(
        SlashSeparatedCourseKey('edx', '999', 'Test_Course'))
    world.log_in()
    world.visit('/courses/edx/999/Test_Course/courseware/')
Esempio n. 50
0
def create_user_and_visit_course():
    world.register_by_course_key(world.scenario_dict['COURSE'].id)
    world.log_in()
    world.visit(u'/courses/{}/courseware/'.format(
        world.scenario_dict['COURSE'].id))
Esempio n. 51
0
def i_visit_the_dashboard(step):
    world.visit('/dashboard')
    assert world.is_css_present('.dashboard')
Esempio n. 52
0
def i_am_not_logged_in(step):
    world.visit('logout')
Esempio n. 53
0
def enable_latex_compiler(step):
    url = world.browser.url
    step.given("I select the Advanced Settings")
    change_value(step, 'use_latex_compiler', True)
    world.visit(url)
    world.wait_for_xmodule()
Esempio n. 54
0
def leave_the_flow_and_return(step):
    world.visit(u'verify_student/verified/{}/'.format(
        world.scenario_dict['course_id']))
Esempio n. 55
0
def and_i_return_to_the_course(step):
    world.visit('/')
    world.click_link("View Course")
    course = 'a[href*="/courseware"]'
    world.css_click(course)
Esempio n. 56
0
def go_to_section(section_name):
    # section name should be one of
    # course_info, membership, student_admin, data_download, analytics, send_email
    world.visit('/courses/edx/999/Test_Course')
    world.css_click('a[href="/courses/edx/999/Test_Course/instructor"]')
    world.css_click('a[data-section="{0}"]'.format(section_name))
Esempio n. 57
0
def main_course_page(step):
    main_page_link = '/{}/{}/course/{}'.format(world.scenario_dict['COURSE'].org,
                                               world.scenario_dict['COURSE'].number,
                                               world.scenario_dict['COURSE'].display_name.replace(' ', '_'),)
    world.visit(main_page_link)
    assert_in('Course Outline', world.css_text('h1.page-header'))
Esempio n. 58
0
def log_out(_step):
    world.visit('logout')
Esempio n. 59
0
def initial_setup(server):
    """
    Launch the browser once before executing the tests.
    """
    world.absorb(settings.LETTUCE_SELENIUM_CLIENT, 'LETTUCE_SELENIUM_CLIENT')

    if world.LETTUCE_SELENIUM_CLIENT == 'local':
        browser_driver = getattr(settings, 'LETTUCE_BROWSER', 'chrome')

        if browser_driver == 'chrome':
            desired_capabilities = DesiredCapabilities.CHROME
            desired_capabilities['loggingPrefs'] = {
                'browser': 'ALL',
            }
        elif browser_driver == 'firefox':
            desired_capabilities = DesiredCapabilities.FIREFOX
        else:
            desired_capabilities = {}

        # There is an issue with ChromeDriver2 r195627 on Ubuntu
        # in which we sometimes get an invalid browser session.
        # This is a work-around to ensure that we get a valid session.
        success = False
        num_attempts = 0
        while (not success) and num_attempts < MAX_VALID_BROWSER_ATTEMPTS:

            # Load the browser and try to visit the main page
            # If the browser couldn't be reached or
            # the browser session is invalid, this will
            # raise a WebDriverException
            try:
                world.browser = Browser(
                    browser_driver, desired_capabilities=desired_capabilities)
                world.browser.driver.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)
                world.visit('/')

            except WebDriverException:
                if hasattr(world, 'browser'):
                    world.browser.quit()
                num_attempts += 1

            else:
                success = True

        # If we were unable to get a valid session within the limit of attempts,
        # then we cannot run the tests.
        if not success:
            raise IOError(
                "Could not acquire valid {driver} browser session.".format(
                    driver=browser_driver))

        world.absorb(0, 'IMPLICIT_WAIT')
        world.browser.driver.set_window_size(1280, 1024)

    elif world.LETTUCE_SELENIUM_CLIENT == 'saucelabs':
        config = get_saucelabs_username_and_key()
        world.browser = Browser(
            'remote',
            url="http://{}:{}@ondemand.saucelabs.com:80/wd/hub".format(
                config['username'], config['access-key']),
            **make_saucelabs_desired_capabilities())
        world.absorb(30, 'IMPLICIT_WAIT')
        world.browser.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)

    elif world.LETTUCE_SELENIUM_CLIENT == 'grid':
        world.browser = Browser(
            'remote',
            url=settings.SELENIUM_GRID.get('URL'),
            browser=settings.SELENIUM_GRID.get('BROWSER'),
        )
        world.absorb(30, 'IMPLICIT_WAIT')
        world.browser.driver.set_script_timeout(GLOBAL_SCRIPT_TIMEOUT)

    else:
        raise Exception("Unknown selenium client '{}'".format(
            world.LETTUCE_SELENIUM_CLIENT))

    world.browser.driver.implicitly_wait(world.IMPLICIT_WAIT)
    world.absorb(world.browser.driver.session_id, 'jobid')
Esempio n. 60
0
def access_unsubscribe_url(step_):
    world.visit("/notification_prefs/unsubscribe/{0}/".format(UNSUB_TOKEN))