Commit 0d94378a by Dean Dieker Committed by Mark L. Chang

smart-accordion work

parent c83bc25b
...@@ -97,3 +97,5 @@ def i_should_see_all_courses(step): ...@@ -97,3 +97,5 @@ def i_should_see_all_courses(step):
course_link_texts = [ (c.location.course, c.display_name) for c in courses] course_link_texts = [ (c.location.course, c.display_name) for c in courses]
for c in course_link_texts: for c in course_link_texts:
assert world.browser.find_element_by_partial_link_text(c[0] + ' ' + c[1]) assert world.browser.find_element_by_partial_link_text(c[0] + ' ' + c[1])
Feature: There are courses on the homepage
In order to compared rendered content to the database
As an acceptance test
I want to count all the chapters, sections, and tabs for each course
Scenario: We can see all the courses
Given I visit "http://localhost:8000/"
I verify all the content of each course
\ No newline at end of file
from lettuce import * #before, world
from selenium import *
import lettuce_webdriver.webdriver
import logging
import nose.tools
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
## imported from lms/djangoapps/courseware/courses.py
from collections import defaultdict
from fs.errors import ResourceNotFoundError
from functools import wraps
import logging
from path import path
from django.conf import settings
from django.http import Http404
from xmodule.course_module import CourseDescriptor
from xmodule.modulestore import Location
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from static_replace import replace_urls, try_staticfiles_lookup
from courseware.access import has_access
## end import
from django.core.urlresolvers import reverse
from courseware.courses import course_image_url, get_course_about_section, get_course_by_id
from courses import *
@step(u'I verify all the content of each course')
def i_verify_all_the_content_of_each_course(step):
courses = get_courses()
for course in courses:
browse_course(course)
## click on a course i'm rgistered for
## extract the course id from the url
## match it to the course id from get_courses() and then walkthrough
def browse_course(step,course,base_url="http://localhost:8000"):
for course in courses:
chapters = course.get_children()
world.browser.get(base_url+'/courses/'+course+'/courseware')
wait_until_id_renders('accordion',2)
rendered_chapters = len(world.browser.find_elements_by_xpath("//*[@id='accordion']//nav//h3"))
assert rendered_chapters == len(chapters)
i = 0
while i < len(chapters):
world.browser.find_element_by_xpath("//*[@id='accordion']//nav//h3["+str(i+1)+"]").click()
sections = chapter.get_children()
accordion_class = "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active"
rendered_sections = world.browser.find_element_by_xpath("//*[@id='accordion']//nav//ul[@class='"+accordion_class+"']//li")
assert rendered_sections == len(sections)
i += 1
if world.browser.find_element_by_xpath("//section[@class='outside-app']"):
assert False
else:
j = 0
while j < len(sections):
section = sections[j]
course.id -> course url betwen /courses/(.*)/info
\ No newline at end of file
...@@ -10,7 +10,7 @@ Feature: Use the Accordion ...@@ -10,7 +10,7 @@ Feature: Use the Accordion
And I login with "password" in the "password" field And I login with "password" in the "password" field
And I press "Access My Courses" And I press "Access My Courses"
I should see an element with class of "user" within "3" seconds I should see an element with class of "user" within "3" seconds
I visit "http://stage-edx-001.m.edx.org/courses/MITx/6.00x/2012_Fall/info" I visit "http://stage-edx-001.m.edx.org/courses/BerkeleyX/CS188.1x/2012_Fall/info"
I click "Courseware" I click "Courseware"
I should see an element with id of "accordion" I should see an element with id of "accordion"
I click on every item in every week of the course I click on every item in every week of the course
\ No newline at end of file
...@@ -33,6 +33,7 @@ def i_click_on_every_item_in_every_week_of_the_course(step): ...@@ -33,6 +33,7 @@ def i_click_on_every_item_in_every_week_of_the_course(step):
section = world.browser.find_element_by_xpath("//*[@id='accordion']//nav//ul[@class='ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active']//li["+str(j)+"]//a//p") section = world.browser.find_element_by_xpath("//*[@id='accordion']//nav//ul[@class='ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active']//li["+str(j)+"]//a//p")
good_section_text = re.sub(r'\s','_',section.text) good_section_text = re.sub(r'\s','_',section.text)
section.click() section.click()
assert world.browser.find_element_by_xpath("//section[@class='outside-app'//h1[@text='THERE HAS BEEN AN ERROR ON THE edX SERVERS']") == None
j += 1 j += 1
clean = re.sub('\"','',good_section_text) clean = re.sub('\"','',good_section_text)
wait_until_id_renders("sequence_i4x-MITx-6_00x-sequential-"+clean,3) wait_until_id_renders("sequence_i4x-MITx-6_00x-sequential-"+clean,3)
...@@ -40,7 +41,11 @@ def i_click_on_every_item_in_every_week_of_the_course(step): ...@@ -40,7 +41,11 @@ def i_click_on_every_item_in_every_week_of_the_course(step):
num_tabs = len(tabs) num_tabs = len(tabs)
l = 1 l = 1
while l <= num_tabs: while l <= num_tabs:
tab = world.browser.find_element_by_xpath("//ol[@id='sequence-list']//li["+str(l)+"]") tab = world.browser.find_element_by_xpath("//ol[@id='sequence-list']//li["+str(l)+"]")
#tab.click() #tab.click()
tab.find_element_by_xpath("//a[@data-element='"+str(l)+"']").click() tab.find_element_by_xpath("//a[@data-element='"+str(l)+"']").click()
l+=1 if world.browser.find_element_by_xpath("//section[@class='outside-app'//h1"):
assert False
else:
l+=1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment