def test_link_on_dashboard_works(self): """ Scenario: Verify that the "Account" link works from the dashboard. Given that I am a registered user And I visit my dashboard And I click on "Account" in the top drop down Then I should see my account settings page """ self.log_in_as_unique_user() dashboard_page = DashboardPage(self.browser) dashboard_page.visit() dashboard_page.click_username_dropdown() self.assertIn('Account', dashboard_page.username_dropdown_link_text) dashboard_page.click_account_settings_link()
def test_link_on_dashboard_works(self): """ Scenario: Verify that the "Account" link works from the dashboard. Given that I am a registered user And I visit my dashboard And I click on "Account" in the top drop down Then I should see my account settings page """ self.log_in_as_unique_user() dashboard_page = DashboardPage(self.browser) dashboard_page.visit() dashboard_page.click_username_dropdown() self.assertIn('Account', dashboard_page.username_dropdown_link_text) dashboard_page.click_account_settings_link()
def test_dashboard_learner_profile_link(self): """ Scenario: Verify that my profile link is present on dashboard page and we can navigate to correct page. Given that I am a registered user. When I go to Dashboard page. And I click on username dropdown. Then I see Profile link in the dropdown menu. When I click on Profile link. Then I will be navigated to Profile page. """ username, __ = self.log_in_as_unique_user() dashboard_page = DashboardPage(self.browser) dashboard_page.visit() self.assertIn('Profile', dashboard_page.tabs_link_text) dashboard_page.click_my_profile_link() my_profile_page = LearnerProfilePage(self.browser, username) my_profile_page.wait_for_page()
def test_dashboard_learner_profile_link(self): """ Scenario: Verify that my profile link is present on dashboard page and we can navigate to correct page. Given that I am a registered user. When I go to Dashboard page. And I click on username dropdown. Then I see Profile link in the dropdown menu. When I click on Profile link. Then I will be navigated to Profile page. """ username, __ = self.log_in_as_unique_user() dashboard_page = DashboardPage(self.browser) dashboard_page.visit() self.assertIn('Profile', dashboard_page.tabs_link_text) dashboard_page.click_my_profile_link() my_profile_page = LearnerProfilePage(self.browser, username) my_profile_page.wait_for_page()
class LMSLanguageTest(UniqueCourseTest): """ Test suite for the LMS Language """ def setUp(self): super(LMSLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit() def test_lms_language_change(self): """ Scenario: Ensure that language selection is working fine. First I go to the user dashboard page in LMS. I can see 'English' is selected by default. Then I choose 'Dummy Language' from drop down (at top of the page). Then I visit the student account settings page and I can see the language has been updated to 'Dummy Language' in both drop downs. After that I select the 'English' language and visit the dashboard page again. Then I can see that top level language selector persist its value to 'English'. """ self.dashboard_page.visit() language_selector = self.dashboard_page.language_selector self.assertEqual( get_selected_option_text(language_selector), u'English' ) select_option_by_text(language_selector, 'Dummy Language (Esperanto)') self.dashboard_page.wait_for_ajax() self.account_settings.visit() self.assertEqual(self.account_settings.value_for_dropdown_field('pref-lang'), u'Dummy Language (Esperanto)') self.assertEqual( get_selected_option_text(language_selector), u'Dummy Language (Esperanto)' ) # changed back to English language. select_option_by_text(language_selector, 'English') self.account_settings.wait_for_ajax() self.assertEqual(self.account_settings.value_for_dropdown_field('pref-lang'), u'English') self.dashboard_page.visit() self.assertEqual( get_selected_option_text(language_selector), u'English' )
class LMSLanguageTest(UniqueCourseTest): """ Test suite for the LMS Language """ def setUp(self): super(LMSLanguageTest, self).setUp() self.dashboard_page = DashboardPage(self.browser) self.account_settings = AccountSettingsPage(self.browser) AutoAuthPage(self.browser).visit() def test_lms_language_change(self): """ Scenario: Ensure that language selection is working fine. First I go to the user dashboard page in LMS. I can see 'English' is selected by default. Then I choose 'Dummy Language' from drop down (at top of the page). Then I visit the student account settings page and I can see the language has been updated to 'Dummy Language' in both drop downs. After that I select the 'English' language and visit the dashboard page again. Then I can see that top level language selector persist its value to 'English'. """ self.dashboard_page.visit() language_selector = self.dashboard_page.language_selector self.assertEqual( get_selected_option_text(language_selector), u'English' ) select_option_by_text(language_selector, 'Dummy Language (Esperanto)') self.dashboard_page.wait_for_ajax() self.account_settings.visit() self.assertEqual(self.account_settings.value_for_dropdown_field('pref-lang'), u'Dummy Language (Esperanto)') self.assertEqual( get_selected_option_text(language_selector), u'Dummy Language (Esperanto)' ) # changed back to English language. select_option_by_text(language_selector, 'English') self.account_settings.wait_for_ajax() self.assertEqual(self.account_settings.value_for_dropdown_field('pref-lang'), u'English') self.dashboard_page.visit() self.assertEqual( get_selected_option_text(language_selector), u'English' )
class BaseLmsDashboardTest(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard """ def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTest, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], ) self.course_fixture.add_advanced_settings({ u"social_sharing_url": {u"value": "http://custom/course/url"} }) self.course_fixture.install() self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) # Create the test user, register them for the course, and authenticate AutoAuthPage( self.browser, username=self.username, email=self.email, course_id=self.course_id ).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
class BaseLmsDashboardTest(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard """ def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTest, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.course_fixture = CourseFixture( self.course_info["org"], self.course_info["number"], self.course_info["run"], self.course_info["display_name"], ) self.course_fixture.add_advanced_settings({ u"social_sharing_url": {u"value": "http://custom/course/url"} }) self.course_fixture.install() self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) # Create the test user, register them for the course, and authenticate AutoAuthPage( self.browser, username=self.username, email=self.email, course_id=self.course_id ).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
class PayAndVerifyTest(EventsTestMixin, UniqueCourseTest): """Test that we can proceed through the payment and verification flow.""" def setUp(self): """Initialize the test. Create the necessary page objects, create a test course and configure its modes, create a user and log them in. """ super(PayAndVerifyTest, self).setUp() self.payment_and_verification_flow = PaymentAndVerificationFlow( self.browser, self.course_id) self.immediate_verification_page = PaymentAndVerificationFlow( self.browser, self.course_id, entry_point='verify-now') self.upgrade_page = PaymentAndVerificationFlow(self.browser, self.course_id, entry_point='upgrade') self.fake_payment_page = FakePaymentPage(self.browser, self.course_id) self.dashboard_page = DashboardPage(self.browser) # Create a course CourseFixture(self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name']).install() # Add an honor mode to the course ModeCreationPage(self.browser, self.course_id).visit() # Add a verified mode to the course ModeCreationPage(self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20').visit() def test_immediate_verification_enrollment(self): # Create a user and log them in student_id = AutoAuthPage(self.browser).visit().get_user_id() enroll_user_track(self.browser, self.course_id, 'verified') # Proceed to verification self.payment_and_verification_flow.immediate_verification() # Take face photo and proceed to the ID photo step self.payment_and_verification_flow.webcam_capture() self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Take ID photo and proceed to the review photos step self.payment_and_verification_flow.webcam_capture() self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Submit photos and proceed to the enrollment confirmation step self.payment_and_verification_flow.next_verification_step( self.immediate_verification_page) # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode( self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified') def test_deferred_verification_enrollment(self): # Create a user and log them in student_id = AutoAuthPage(self.browser).visit().get_user_id() enroll_user_track(self.browser, self.course_id, 'verified') # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode( self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified') def test_enrollment_upgrade(self): # Create a user, log them in, and enroll them in the honor mode student_id = AutoAuthPage( self.browser, course_id=self.course_id).visit().get_user_id() # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as honor in the course enrollment_mode = self.dashboard_page.get_enrollment_mode( self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'honor') # Click the upsell button on the dashboard self.dashboard_page.upgrade_enrollment( self.course_info["display_name"], self.upgrade_page) # Select the first contribution option appearing on the page self.upgrade_page.indicate_contribution() # Proceed to the fake payment page self.upgrade_page.proceed_to_payment() def only_enrollment_events(event): """Filter out all non-enrollment events.""" return event['event_type'].startswith('edx.course.enrollment.') expected_events = [{ 'event_type': 'edx.course.enrollment.mode_changed', 'event': { 'user_id': int(student_id), 'mode': 'verified', } }] with self.assert_events_match_during( event_filter=only_enrollment_events, expected_events=expected_events): # Submit payment self.fake_payment_page.submit_payment() # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode( self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified')
class BaseLmsDashboardTestMultiple(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard with Multiple Courses""" def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTestMultiple, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.courses = { 'A': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_A', 'display_name': 'Test Course A', 'enrollment_mode': 'audit', 'cert_name_long': 'Certificate of Audit Achievement' }, 'B': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_B', 'display_name': 'Test Course B', 'enrollment_mode': 'verified', 'cert_name_long': 'Certificate of Verified Achievement' }, 'C': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_C', 'display_name': 'Test Course C', 'enrollment_mode': 'credit', 'cert_name_long': 'Certificate of Credit Achievement' } } self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) self.course_keys = {} self.course_fixtures = {} for key, value in self.courses.iteritems(): course_key = generate_course_key( value['org'], value['number'], value['run'], ) course_fixture = CourseFixture( value['org'], value['number'], value['run'], value['display_name'], ) course_fixture.add_advanced_settings({ u"social_sharing_url": { u"value": "http://custom/course/url" }, u"cert_name_long": { u"value": value['cert_name_long'] } }) course_fixture.install() self.course_keys[key] = course_key self.course_fixtures[key] = course_fixture # Create the test user, register them for the course, and authenticate AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=course_key, enrollment_mode=value['enrollment_mode']).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
class PayAndVerifyTest(EventsTestMixin, UniqueCourseTest): """Test that we can proceed through the payment and verification flow.""" def setUp(self): """Initialize the test. Create the necessary page objects, create a test course and configure its modes, create a user and log them in. """ super(PayAndVerifyTest, self).setUp() self.payment_and_verification_flow = PaymentAndVerificationFlow(self.browser, self.course_id) self.immediate_verification_page = PaymentAndVerificationFlow(self.browser, self.course_id, entry_point='verify-now') self.upgrade_page = PaymentAndVerificationFlow(self.browser, self.course_id, entry_point='upgrade') self.fake_payment_page = FakePaymentPage(self.browser, self.course_id) self.dashboard_page = DashboardPage(self.browser) # Create a course CourseFixture( self.course_info['org'], self.course_info['number'], self.course_info['run'], self.course_info['display_name'] ).install() # Add an honor mode to the course ModeCreationPage(self.browser, self.course_id).visit() # Add a verified mode to the course ModeCreationPage(self.browser, self.course_id, mode_slug=u'verified', mode_display_name=u'Verified Certificate', min_price=10, suggested_prices='10,20').visit() def test_deferred_verification_enrollment(self): # Create a user and log them in student_id = AutoAuthPage(self.browser).visit().get_user_id() enroll_user_track(self.browser, self.course_id, 'verified') # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode(self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified') def test_enrollment_upgrade(self): # Create a user, log them in, and enroll them in the honor mode student_id = AutoAuthPage(self.browser, course_id=self.course_id).visit().get_user_id() # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as honor in the course enrollment_mode = self.dashboard_page.get_enrollment_mode(self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'honor') # Click the upsell button on the dashboard self.dashboard_page.upgrade_enrollment(self.course_info["display_name"], self.upgrade_page) # Select the first contribution option appearing on the page self.upgrade_page.indicate_contribution() # Proceed to the fake payment page self.upgrade_page.proceed_to_payment() def only_enrollment_events(event): """Filter out all non-enrollment events.""" return event['event_type'].startswith('edx.course.enrollment.') expected_events = [ { 'event_type': 'edx.course.enrollment.mode_changed', 'event': { 'user_id': int(student_id), 'mode': 'verified', } } ] with self.assert_events_match_during(event_filter=only_enrollment_events, expected_events=expected_events): # Submit payment self.fake_payment_page.submit_payment() # Navigate to the dashboard self.dashboard_page.visit() # Expect that we're enrolled as verified in the course enrollment_mode = self.dashboard_page.get_enrollment_mode(self.course_info["display_name"]) self.assertEqual(enrollment_mode, 'verified')
class BaseLmsDashboardTestMultiple(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard with Multiple Courses""" def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTestMultiple, self).setUp() # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.courses = { 'A': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_A', 'display_name': 'Test Course A', 'enrollment_mode': 'audit', 'cert_name_long': 'Certificate of Audit Achievement' }, 'B': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_B', 'display_name': 'Test Course B', 'enrollment_mode': 'verified', 'cert_name_long': 'Certificate of Verified Achievement' }, 'C': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_C', 'display_name': 'Test Course C', 'enrollment_mode': 'credit', 'cert_name_long': 'Certificate of Credit Achievement' } } self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) self.course_keys = {} self.course_fixtures = {} for key, value in self.courses.iteritems(): course_key = generate_course_key( value['org'], value['number'], value['run'], ) course_fixture = CourseFixture( value['org'], value['number'], value['run'], value['display_name'], ) course_fixture.add_advanced_settings({ u"social_sharing_url": {u"value": "http://custom/course/url"}, u"cert_name_long": {u"value": value['cert_name_long']} }) course_fixture.install() self.course_keys[key] = course_key self.course_fixtures[key] = course_fixture # Create the test user, register them for the course, and authenticate AutoAuthPage( self.browser, username=self.username, email=self.email, course_id=course_key, enrollment_mode=value['enrollment_mode'] ).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()
class BaseLmsDashboardTestMultiple(UniqueCourseTest): """ Base test suite for the LMS Student Dashboard with Multiple Courses""" def setUp(self): """ Initializes the components (page objects, courses, users) for this test suite """ # Some parameters are provided by the parent setUp() routine, such as the following: # self.course_id, self.course_info, self.unique_id super(BaseLmsDashboardTestMultiple, self).setUp() # lint-amnesty, pylint: disable=super-with-arguments # Load page objects for use by the tests self.dashboard_page = DashboardPage(self.browser) # Configure some aspects of the test course and install the settings into the course self.courses = { 'A': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_A', 'display_name': 'Test Course A', 'enrollment_mode': 'audit', 'cert_name_long': 'Certificate of Audit Achievement' }, 'B': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_B', 'display_name': 'Test Course B', 'enrollment_mode': 'verified', 'cert_name_long': 'Certificate of Verified Achievement' }, 'C': { 'org': 'test_org', 'number': self.unique_id, 'run': 'test_run_C', 'display_name': 'Test Course C', 'enrollment_mode': 'credit', 'cert_name_long': 'Certificate of Credit Achievement' } } self.username = "******".format(uuid=self.unique_id[0:6]) self.email = "{user}@example.com".format(user=self.username) self.course_keys = {} self.course_fixtures = {} for key, value in six.iteritems(self.courses): course_key = generate_course_key( value['org'], value['number'], value['run'], ) course_fixture = CourseFixture( value['org'], value['number'], value['run'], value['display_name'], ) course_fixture.add_advanced_settings({ u"social_sharing_url": { u"value": "http://custom/course/url" }, u"cert_name_long": { u"value": value['cert_name_long'] } }) course_fixture.add_children( XBlockFixtureDesc('chapter', 'Test Section 1').add_children( XBlockFixtureDesc('sequential', 'Test Subsection 1,1'). add_children( XBlockFixtureDesc( 'problem', 'Test Problem 1', data='<problem>problem 1 dummy body</problem>'), XBlockFixtureDesc( 'html', 'html 1', data="<html>html 1 dummy body</html>"), XBlockFixtureDesc( 'problem', 'Test Problem 2', data="<problem>problem 2 dummy body</problem>"), XBlockFixtureDesc( 'html', 'html 2', data="<html>html 2 dummy body</html>"), ), XBlockFixtureDesc('sequential', 'Test Subsection 1,2'). add_children( XBlockFixtureDesc( 'problem', 'Test Problem 3', data='<problem>problem 3 dummy body</problem>'), ), XBlockFixtureDesc( 'sequential', 'Test HIDDEN Subsection', metadata={ 'visible_to_staff_only': True }).add_children( XBlockFixtureDesc( 'problem', 'Test HIDDEN Problem', data='<problem>hidden problem</problem>'), ), )).install() self.course_keys[key] = course_key self.course_fixtures[key] = course_fixture # Create the test user, register them for the course, and authenticate AutoAuthPage(self.browser, username=self.username, email=self.email, course_id=course_key, enrollment_mode=value['enrollment_mode']).visit() # Navigate the authenticated, enrolled user to the dashboard page and get testing! self.dashboard_page.visit()