本文整理匯總了Python中staxing.helper.Teacher.logout方法的典型用法代碼示例。如果您正苦於以下問題:Python Teacher.logout方法的具體用法?Python Teacher.logout怎麽用?Python Teacher.logout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類staxing.helper.Teacher
的用法示例。
在下文中一共展示了Teacher.logout方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestEditCourseSettingsAndRoster
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
#.........這裏部分代碼省略.........
(By.XPATH, '//input[contains(@class,"form-control")]')
)
).send_keys(Keys.BACK_SPACE)
self.teacher.find(
By.XPATH,
'//button[contains(@class,"edit-course-confirm")]'
).click()
self.teacher.wait.until(
expect.visibility_of_element_located(
(By.XPATH, '//div[@class="course-settings-title"]' +
'/span[text()="%s"]' % course_name)
)
)
self.ps.test_updates['passed'] = True
# Case C8259 - 002 - Teacher | Remove an instructor from the course
@pytest.mark.skipif(str(8259) not in TESTS, reason='Excluded')
def test_teacher_remove_an_instructor_from_a_course_8259(self):
"""Remove an instructor from the course.
Steps:
Click "Remove" for an instructor under the Instructors section
Click "Remove" on the box that pops up
Expected Result:
The instructor is removed from the Instructors list.
"""
self.ps.test_updates['name'] = 't1.42.002' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = ['t1', 't1.42', 't1.42.002', '8259']
self.ps.test_updates['passed'] = False
self.teacher.logout()
# add extra instructor through admin first
admin = Admin(
use_env_vars=True,
existing_driver=self.teacher.driver,
pasta_user=self.ps,
capabilities=self.desired_capabilities
)
admin.login()
admin.get('https://tutor-qa.openstax.org/admin/courses/1/edit')
admin.page.wait_for_page_load()
teacher_name = 'Trent'
admin.find(
By.XPATH, '//a[contains(text(),"Teachers")]').click()
admin.find(
By.ID, 'course_teacher').send_keys(teacher_name)
admin.wait.until(
expect.visibility_of_element_located(
(By.XPATH, '//li[contains(text(),"%s")]' % teacher_name)
)
).click()
admin.sleep(1)
admin.find(
By.LINK_TEXT, 'Main Dashboard').click()
admin.page.wait_for_page_load()
admin.logout()
# redo set-up, but make sure to go to course 1
self.teacher.login()
self.teacher.get('https://tutor-qa.openstax.org/courses/1')
self.teacher.open_user_menu()
self.teacher.wait.until(
expect.element_to_be_clickable(
(By.LINK_TEXT, 'Course Settings and Roster')
示例2: TestCreateNewQuestionAndAssignmentTypes
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
#.........這裏部分代碼省略.........
# NOT DONE
# same issue as above w/ add_homework helper
# but works for manually created assignemnt
# (add assignemnt gets commented out, manual assignemnt name added)
# 14744 - 005 - Student | Each part of a multi-part question counts as a
# seperate problem when scored
@pytest.mark.skipif(str(14744) not in TESTS, reason='Excluded')
def test_student_each_part_of_a_multipart_question_counts_as_14744(self):
"""Multi-part questions count as seperate problems when scored.
Steps:
Go to Tutor
Click on the 'Login' button
Log in as abarnes
Click "College Introduction to Sociology"
Click on a homework assignment
Go through the questions
Expected Result:
There is a breadcrumb for each part in the multipart question and the
progress/score is out of the total number of questions, rather than
counting the multipart question as one question
"""
self.ps.test_updates['name'] = 't2.12.005' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = ['t2', 't2.12', 't2.12.005', '14744']
self.ps.test_updates['passed'] = False
# Test steps and verification assertions
# create a hw with a multi part question, and give it a randomized name
# ID: [email protected] is multi part
self.teacher.login()
self.teacher.find(
By.XPATH,
'//div[@data-appearance="intro_sociology"]' +
'//a[not(contains(@href,"/cc-dashboard"))]'
).click()
assignment_name = "homework-%s" % randint(100, 999)
today = datetime.date.today()
begin = (today + datetime.timedelta(days=0)).strftime('%m/%d/%Y')
end = (today + datetime.timedelta(days=100)).strftime('%m/%d/%Y')
self.teacher.add_assignment(
assignment='homework',
args={
'title': assignment_name,
'description': 'description',
'periods': {'all': (begin, end)},
'problems': {'1.1': ['[email protected]'], },
'status': 'publish',
}
)
self.teacher.logout()
# assignemnt name put here for manual testing
# assignment_name = 'hw w/ video and multi part question'
# login as student and go to same class
self.student.login()
self.teacher.find(
By.XPATH,
'//div[@data-appearance="intro_sociology"]' +
'//a[not(contains(@href,"/cc-dashboard"))]'
).click()
self.student.page.wait_for_page_load()
# go to assignment (find my assignemnt_name)
self.student.find(
By.XPATH,
'//a[contains(@class,"homework workable")]' +
'//span[text()="' + assignment_name + '"]'
).click()
# go through all questions
breadcrumbs = self.teacher.find_all(
By.XPATH,
'//span[contains(@class,"openstax-breadcrumb")' +
' and not(contains(@class,"intro"))' +
' and not(contains(@class,"personalized"))'
' and not(contains(@class,"end"))]')
total_questions = 0
found_multipart = False
i = 0
while i < len(breadcrumbs):
breadcrumbs[i].click()
try:
self.student.find(
By.XPATH, '//span[text()="Multi-part question"]')
found_multipart = True
questions = self.teacher.find_all(
By.XPATH, '//div[contains(@class,"openstax-question")]')
total_questions += len(questions)
i += len(questions)
except NoSuchElementException:
i += 1
questions = self.teacher.find_all(
By.XPATH, '//div[contains(@class,"openstax-question")]')
total_questions += len(questions)
# check that everything worked out
assert(found_multipart), 'no multipart question found'
assert(total_questions == len(breadcrumbs)), \
'breadcrumbs and questions not equal'
self.ps.test_updates['passed'] = True
示例3: TestViewTheCalendarDashboard
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
#.........這裏部分代碼省略.........
"""Click on the course name to return to the dashboard.
Steps:
If the user has more than one course, click on a Tutor course name
Click on the 'Performance Forecast' button
Click on the course name in the header
Expected Result:
The teacher is presented with their calendar dashboard
"""
self.ps.test_updates['name'] = 't1.13.012' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = ['t1', 't1.13', 't1.13.012', '7989']
self.ps.test_updates['passed'] = False
self.teacher.open_user_menu()
self.teacher.driver.find_element(
By.CLASS_NAME,
'viewTeacherPerformanceForecast'
).click()
self.teacher.driver.find_element(
By.CLASS_NAME,
'course-name'
).click()
assert('calendar' in self.teacher.current_url()), \
'Not viewing the calendar dashboard'
self.ps.test_updates['passed'] = True
# Case C7990 - 013 - Teacher | Cick on the OpenStax logo to return to
# the course picker
@pytest.mark.skipif(str(7990) not in TESTS, reason='Excluded')
def test_teacher_click_openstax_logo_to_return_to_course_picker_7990(self):
"""Cick on the OpenStax logo to return to the course picker.
Steps:
If the user has more than one course, click on a Tutor course name
Click in the OpenStax logo in the header
Expected Result:
The teacher is presented with the course picker
"""
self.ps.test_updates['name'] = 't1.13.013' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = ['t1', 't1.13', 't1.13.013', '7990']
self.ps.test_updates['passed'] = False
# self.teacher.select_course(appearance='physics')
self.teacher.driver.find_element(
By.CLASS_NAME,
'ui-brand-logo'
).click()
assert('dashboard' in self.teacher.current_url()), \
'Not viewing the course picker'
self.ps.test_updates['passed'] = True
# Case C7991 - 014 - Teacher | CLick in the OpenStax logo to return to the
# dashboard
@pytest.mark.skipif(str(7991) not in TESTS, reason='Excluded')
def test_teacher_clicks_openstax_logo_to_return_to_dashboard_7991(self):
"""CLick in the OpenStax logo to return to the dashboard.
Steps:
Click on the 'Performance Forecast' button
Click on the OpenStax logo in the header
Expected Result:
The teacher is presented with their calendar dashboard
"""
self.ps.test_updates['name'] = 't1.13.014' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = ['t1', 't1.13', 't1.13.014', '7991']
self.ps.test_updates['passed'] = False
self.teacher.logout()
teacher2 = Teacher(
username=os.getenv('TEACHER_USER_ONE_COURSE'),
password=os.getenv('TEACHER_PASSWORD'),
site='https://tutor-qa.openstax.org',
existing_driver=self.teacher.driver,
pasta_user=self.ps,
capabilities=self.desired_capabilities,
)
print(teacher2.username)
print(teacher2.password)
teacher2.login()
self.teacher.open_user_menu()
self.teacher.driver.find_element(
By.CLASS_NAME,
'viewTeacherPerformanceForecast'
).click()
self.teacher.driver.find_element(
By.CLASS_NAME,
'ui-brand-logo'
).click()
assert('calendar' in self.teacher.current_url()), \
'Not viewing the calendar dashboard'
self.ps.test_updates['passed'] = True
示例4: TestStudentsWorkAssignments
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
class TestStudentsWorkAssignments(unittest.TestCase):
"""CC1.08 - Students Work Assignments."""
def setUp(self):
"""Pretest settings."""
self.ps = PastaSauce()
self.desired_capabilities['name'] = self.id()
self.teacher = Teacher(
username=os.getenv('TEACHER_USER_CC'),
password=os.getenv('TEACHER_PASSWORD'),
pasta_user=self.ps,
capabilities=self.desired_capabilities
)
self.teacher.login()
if 'cc-dashboard' not in self.teacher.current_url():
courses = self.teacher.find_all(
By.CLASS_NAME,
'tutor-booksplash-course-item'
)
assert(courses), 'No courses found.'
if not isinstance(courses, list):
courses = [courses]
course_id = randint(0, len(courses) - 1)
self.course = courses[course_id].get_attribute('data-title')
self.teacher.select_course(title=self.course)
self.teacher.goto_course_roster()
try:
section = self.teacher.find_all(
By.XPATH,
'//*[contains(@class,"nav-tabs")]//a'
)
if isinstance(section, list):
section = '%s' % section[randint(0, len(section) - 1)].text
else:
section = '%s' % section.text
except Exception:
section = '%s' % randint(100, 999)
self.teacher.add_course_section(section)
self.code = self.teacher.get_enrollment_code(section)
print('Course Phrase: ' + self.code)
self.book_url = self.teacher.find(
By.XPATH, '//a[span[contains(text(),"Online Book")]]'
).get_attribute('href')
self.teacher.find(By.CSS_SELECTOR, 'button.close').click()
self.teacher.sleep(0.5)
self.teacher.logout()
self.teacher.sleep(1)
self.student = Student(use_env_vars=True,
existing_driver=self.teacher.driver)
self.first_name = Assignment.rword(6)
self.last_name = Assignment.rword(8)
self.email = self.first_name + '.' \
+ self.last_name \
+ '@tutor.openstax.org'
def tearDown(self):
"""Test destructor."""
self.ps.update_job(
job_id=str(self.teacher.driver.session_id),
**self.ps.test_updates
)
try:
self.teacher.delete()
except:
pass
# Case C7691 - 001 - Student | Selects an exercise answer
@pytest.mark.skipif(str(7691) not in TESTS, reason='Excluded')
def test_student_select_an_exercise_answer_7691(self):
"""Select an exercise answer."""
self.ps.test_updates['name'] = 'cc1.08.001' \
+ inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates['tags'] = [
'cc1',
'cc1.08',
'cc1.08.001',
'7691'
]
self.ps.test_updates['passed'] = False
# Test steps and verification assertions
self.student.get(self.book_url)
self.student.sleep(2)
self.student.find_all(By.XPATH, '//a[@class="nav next"]')[0].click()
self.student.page.wait_for_page_load()
try:
widget = self.student.find(By.ID, 'coach-wrapper')
except:
self.student.find_all(By.XPATH,
'//a[@class="nav next"]')[0].click()
self.student.page.wait_for_page_load()
try:
self.student.sleep(1)
widget = self.student.find(By.ID, 'coach-wrapper')
except:
self.student.find_all(By.XPATH,
'//a[@class="nav next"]')[0].click()
self.student.page.wait_for_page_load()
self.student.sleep(1)
widget = self.student.find(By.ID, 'coach-wrapper')
#.........這裏部分代碼省略.........
示例5: TestSimplifyAndImproveReadings
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
class TestSimplifyAndImproveReadings(unittest.TestCase):
"""T2.13 - Simplify and Improve Readings."""
def setUp(self):
"""Pretest settings."""
self.ps = PastaSauce()
self.desired_capabilities["name"] = self.id()
self.teacher = Teacher(use_env_vars=True, pasta_user=self.ps, capabilities=self.desired_capabilities)
# create a reading for the student to work
self.teacher.login()
self.assignment_name = "t1.18 reading-%s" % randint(100, 999)
today = datetime.date.today()
begin = today.strftime("%m/%d/%Y")
end = (today + datetime.timedelta(days=randint(1, 10))).strftime("%m/%d/%Y")
self.teacher.add_assignment(
assignment="reading",
args={
"title": self.assignment_name,
"description": chomsky(),
"periods": {"all": (begin, end)},
"reading_list": ["1.1", "1.2"],
"status": "publish",
},
)
self.teacher.wait.until(
expect.visibility_of_element_located((By.XPATH, '//div[contains(@class,"calendar-container")]'))
)
self.teacher.logout()
# login as a student to work the reading
self.student = Student(
existing_driver=self.teacher.driver,
use_env_vars=True,
pasta_user=self.ps,
capabilities=self.desired_capabilities,
)
self.student.login()
self.student.wait.until(expect.visibility_of_element_located((By.LINK_TEXT, "This Week")))
reading = self.student.driver.find_element(By.XPATH, '//span[text()="%s"]' % self.assignment_name)
self.teacher.driver.execute_script("return arguments[0].scrollIntoView();", reading)
self.teacher.driver.execute_script("window.scrollBy(0, -80);")
reading.click()
def tearDown(self):
"""Test destructor."""
self.ps.update_job(job_id=str(self.teacher.driver.session_id), **self.ps.test_updates)
self.student = None
try:
self.teacher.delete()
except:
pass
# 14745 - 001 - Student | Relative size and progress are displayed while
# working a reading assignment
@pytest.mark.skipif(str(14745) not in TESTS, reason="Excluded")
def test_student_relative_size_and_progress_are_displayed_whil_14745(self):
"""Size and progress are displayed while working a reading.
Steps:
Go to Tutor
Click on the 'Login' button
Enter the student user account in the username and password text boxes
Click on the 'Sign in' button
If the user has more than one course, click on a Tutor course name
Click on a reading assignment
Click on the right arrow
Expected Result:
The progress bar at the top reflects how far along you are as you work
through the reading assignment
"""
self.ps.test_updates["name"] = "t2.13.001" + inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates["tags"] = ["t2", "t2.13", "t2.13.001", "14745"]
self.ps.test_updates["passed"] = False
# Test steps and verification assertions
self.student.driver.find_element(By.XPATH, '//div[contains(@class,"progress-bar progress-bar-success")]')
self.ps.test_updates["passed"] = True
# 14746 - 002 - Student | Access prior milestones in the reading assignment
# with breadcrumbs
@pytest.mark.skipif(str(14746) not in TESTS, reason="Excluded")
def test_student_access_prior_milestones_in_the_reading_assign_14746(self):
"""Access prior milestones in the reading assignment with breadcrumbs.
Steps:
If the user has more than one course, click on a Tutor course name
Click on a reading assignment
Click on the icon next to the calendar on the header
Expected Result:
The user is presented with prior milestones
"""
self.ps.test_updates["name"] = "t2.13.002" + inspect.currentframe().f_code.co_name[4:]
self.ps.test_updates["tags"] = ["t2", "t2.13", "t2.13.002", "14746"]
self.ps.test_updates["passed"] = False
# Test steps and verification assertions
self.student.find(By.CSS_SELECTOR, "a.paging-control.next").click()
self.student.sleep(1)
#.........這裏部分代碼省略.........
示例6: TestImproveLoginRegistrationEnrollment
# 需要導入模塊: from staxing.helper import Teacher [as 別名]
# 或者: from staxing.helper.Teacher import logout [as 別名]
class TestImproveLoginRegistrationEnrollment(unittest.TestCase):
"""CC2.09 - Improve Login, Registration, Enrollment."""
def setUp(self):
"""Pretest settings."""
self.ps = PastaSauce()
self.desired_capabilities['name'] = self.id()
self.teacher = Teacher(
use_env_vars=True,
pasta_user=self.ps,
capabilities=self.desired_capabilities
)
self.student = Student(
use_env_vars=True,
existing_driver=self.teacher.driver,
pasta_user=self.ps,
capabilities=self.desired_capabilities
)
def tearDown(self):
"""Test destructor."""
self.ps.update_job(
job_id=str(self.teacher.driver.session_id),
**self.ps.test_updates
)
try:
self.student.delete()
except:
pass
try:
self.teacher.delete()
except:
pass
def get_enrollemnt_code(self, number=0):
"""
Steps:
Sign in as teacher
Click on a Concept Coach course
Click on "Course Settings and Roster" from the user menu
Click "Your Student Enrollment Code"
Return value: code, enrollemnt_url
code - enrollment code
enrollemnt_url - url of book for course
"""
self.teacher.login()
if number != 0:
cc_courses = self.teacher.find_all(
By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
)
cc_courses[number].click()
else:
self.teacher.find(
By.XPATH, '//a[contains(@href,"/cc-dashboard")]'
).click()
self.teacher.open_user_menu()
self.teacher.find(
By.LINK_TEXT, 'Course Settings and Roster'
).click()
self.teacher.find(
By.XPATH, '//span[contains(text(),"Your student enrollment code")]'
).click()
self.teacher.sleep(1)
code = self.teacher.find(
By.XPATH, '//p[@class="code"]'
).text
enrollement_url = self.teacher.find(
By.XPATH, '//textarea'
).text
enrollement_url = enrollement_url.split('\n')[5]
self.teacher.find(
By.XPATH, '//button[@class="close"]'
).click()
self.teacher.sleep(0.5)
self.teacher.logout()
return code, enrollement_url
def create_user(self, start_num, end_num):
"""
creates a new user and return the username
"""
self.student.get("http://accounts-qa.openstax.org")
num = str(randint(start_num, end_num))
self.student.find(By.LINK_TEXT, 'Sign up').click()
self.student.find(
By.ID, 'identity-login-button').click()
self.student.find(
By.ID, 'signup_first_name').send_keys('first_name_001')
self.student.find(
By.ID, 'signup_last_name').send_keys('last_name_001')
self.student.find(
By.ID, 'signup_email_address').send_keys('[email protected]')
self.student.find(
By.ID, 'signup_username').send_keys('automated_09_'+num)
self.student.find(
By.ID, 'signup_password'
).send_keys(os.getenv('STUDENT_PASSWORD'))
self.student.find(
By.ID, 'signup_password_confirmation'
#.........這裏部分代碼省略.........