Exemple #1
0
    def setUp(self):
        """
        Common setup for component tests
        """
        super(StudioLmsComponentBaseTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.unit_container_page = UnitPageExtended(self.browser, None)

        self.studio_home_page = DashboardPageExtended(self.browser)

        self.course_info = get_course_info()

        self.studio_course_outline = CourseOutlinePageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])

        self.lms_courseware = CoursewarePageExtended(
            self.browser, get_course_key(self.course_info))
        self.studio_course_outline.visit()
        # Delete any existing sections
        self.studio_course_outline.delete_all_sections()
 def setUp(self):
     """
     Initialize all page objects
     """
     super(EnterpriseTestBase, self).setUp()
     self.browser.maximize_window()
     self.ent_portal_login = EnterprisePortalLogin(self.browser)
     self.ent_portal_home = EnterprisePortalHome(self.browser)
     self.ent_portal_course_start = \
         EnterprisePortalCourseStart(self.browser)
     self.ent_portal_course_structure = \
         EnterprisePortalCourseStructure(self.browser)
     self.ent_course_enrollment = \
         EnterpriseCourseEnrollment(self.browser)
     self.ent_data_sharing_consent = \
         EnterpriseDataSharingConsentPage(self.browser)
     self.ecommerce_courses_page = \
         EcommerceCoursesPage(self.browser)
     self.lms_login = LmsLogin(self.browser)
     self.ent_edx_registration = EnterpriseEdxRegistration(self.browser)
     self.ent_edx_login = EnterpriseEdxLogin(self.browser)
     self.dashboard = DashboardPageExtended(self.browser)
     self.courses_page = CoursesPage(self.browser)
     self.course_about_page = CourseAboutPageExtended(self.browser)
     self.track_selection_page = TrackSelectionPage(self.browser)
     self.user_account = UserAccountSettings(self.browser)
     self.cyber_source_page = CyberSourcePage(self.browser)
     self.single_seat_basket = SingleSeatBasketPage(self.browser)
     self.receipt_page = ReceiptPage(self.browser)
     self.lms_api_client = LmsApiClient()
     self.login_api = LmsLoginApi()
     self.logout_api = LogoutApi()
    def setUp(self):
        """
        Common setup for component tests
        """
        super(StudioLmsComponentBaseTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.unit_container_page = UnitPageExtended(
            self.browser, None
        )

        self.studio_home_page = DashboardPageExtended(self.browser)

        self.course_info = get_course_info()

        self.studio_course_outline = CourseOutlinePageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])

        self.lms_courseware = CoursewarePageExtended(
            self.browser,
            get_course_key(self.course_info)
        )
        self.studio_course_outline.visit()
        # Delete any existing sections
        self.studio_course_outline.delete_all_sections()
Exemple #4
0
    def setUp(self):
        super(DashboardTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.studio_home_page = DashboardPageExtended(self.browser)
        self.course_info = get_course_info()
        self.studio_course_outline = CourseOutlinePageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run']
        )
        self.lms_courseware = CoursewarePageExtended(
            self.browser,
            get_course_key(self.course_info)
        )
        self.course_page = CourseHomePageExtended(
            self.browser, get_course_info()
        )
        self.dashboard_page = DashboardPageExtended(self.browser)

        self.dashboard_page.visit()
Exemple #5
0
    def setUp(self):
        super(DashboardTest, self).setUp()

        login_api = LmsLoginApi()
        login_api.authenticate(self.browser)

        self.dashboard_page = DashboardPageExtended(self.browser)
        self.drupal_course_page = DemoCourseSelectionPage(self.browser)
        self.payment_page = PaymentPage(self.browser)
        self.dashboard_page.visit()
    def setUp(self):
        super(CourseHandoutTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()

        self.course_update_page = CourseUpdatesPageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
        self.course_update_page.visit()
Exemple #7
0
    def setUp(self):
        super(ScheduleAndDetailsTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()

        self.settings_page = SettingsPageExtended(self.browser,
                                                  self.course_info['org'],
                                                  self.course_info['number'],
                                                  self.course_info['run'])
        self.settings_page.visit()
    def test_course_pages(self):
        """
        Verifies that user can navigate to LMS Pages
        """
        # Log in as a student
        login_api = LmsLoginApi()
        login_api.authenticate(self.browser)
        dashboard_page = DashboardPageExtended(self.browser)
        dashboard_page.visit()

        visit_all([
            clz(self.browser, 'course-v1:ArbiRaees+AR-1000+fall') for clz in
            [CourseInfoPageExtended]
        ])
    def setUp(self):
        super(CourseUpdateTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()

        self.course_update_page = CourseUpdatesPageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
        self.course_update_page.visit()
        self.course_update_content_selector = '#course-update-list li' \
                                              ' .post-preview .update-contents'
        self.course_update_text = 'New update:{}'.format(uuid4().hex)
    def setUp(self):
        """
        Initialize the page object
        """
        super(StudioHomeTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.studio_home_page = DashboardPageExtended(self.browser)

        self.course_info = get_course_info()

        self.studio_course_outline = CourseOutlinePage(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
Exemple #11
0
 def setUp(self):
     """
     Initialize all page objects
     """
     super(EnterpriseTestBase, self).setUp()
     self.browser.maximize_window()
     self.ent_portal_login = EnterprisePortalLogin(self.browser)
     self.ent_portal_home = EnterprisePortalHome(self.browser)
     self.ent_portal_course_start = \
         EnterprisePortalCourseStart(self.browser)
     self.ent_portal_course_structure = \
         EnterprisePortalCourseStructure(self.browser)
     self.ent_course_enrollment = \
         EnterpriseCourseEnrollment(self.browser)
     self.ent_data_sharing_consent = \
         EnterpriseDataSharingConsentPage(self.browser)
     self.ecommerce_courses_page = \
         EcommerceCoursesPage(self.browser)
     self.lms_login = LmsLogin(self.browser)
     self.ent_edx_registration = EnterpriseEdxRegistration(self.browser)
     self.ent_edx_login = EnterpriseEdxLogin(self.browser)
     self.dashboard = DashboardPageExtended(self.browser)
     self.courses_page = CoursesPage(self.browser)
     self.course_about_page = CourseAboutPageExtended(self.browser)
     self.track_selection_page = TrackSelectionPage(self.browser)
     self.user_account = UserAccountSettings(self.browser)
     self.cyber_source_page = CyberSourcePage(self.browser)
     self.single_seat_basket = SingleSeatBasketPage(self.browser)
     self.receipt_page = ReceiptPage(self.browser)
     self.lms_api_client = LmsApiClient()
     self.login_api = LmsLoginApi()
     self.logout_api = LogoutApi()
    def setUp(self):
        super(AnalyticsTest, self).setUp()

        login_api = LmsLoginApi()
        login_api.authenticate(self.browser)

        course_info = get_course_info()
        self.dashboard_page = DashboardPageExtended(self.browser)
        self.instructor_dashboard = InstructorDashboardPageExtended(
            self.browser, get_course_key(course_info))
        self.course_page = CourseHomePageExtended(self.browser,
                                                  get_course_key(course_info))
        self.dashboard_page.visit()
        self.dashboard_page.select_course(get_course_display_name())
        self.course_page.wait_for_page()
        self.instructor_dashboard.visit()
Exemple #13
0
    def setUp(self):
        """
        Initialize the page object
        """
        super(TestVideoUploadHelp, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()
        self.video_upload_page = VideoUploadPage(self.browser,
                                                 self.course_info['org'],
                                                 self.course_info['number'],
                                                 self.course_info['run'])

        self.video_upload_page.visit()
Exemple #14
0
    def setUp(self):
        super(TextbookTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.lms_textbook = TextbookPage(self.browser)
        self.course_info = get_course_info()

        self.textbook_page = TextbookPageExtended(self.browser,
                                                  self.course_info['org'],
                                                  self.course_info['number'],
                                                  self.course_info['run'])

        self.textbook_page.visit()
Exemple #15
0
 def login_and_unlink_account(self):
     """
     Unlink IDP Account
     This serves as a fixture for unlinked user test case, it unlinks the
     user before running the tests to make sure that the precondition
     of test is true
     """
     # Login using api and transfer session to browser
     lms_login_api = LmsLoginApi('/account/settings')
     lms_login_api.authenticate(self.browser)
     # Visit account setting page
     # self.user_account.visit()
     self.user_account.switch_account_settings_tabs('accounts-tab')
     # If linked account is found, unlink it
     if self.user_account.is_idp_account_linked(IDP_CSS_ID):
         self.user_account.unlink_idp_account(IDP_CSS_ID)
     # Logout using api
     self.logout_from_lms_using_api()
    def setUp(self):
        """
        Initialize the page object
        """
        super(StudioFooterTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.terms_of_service = TermsOfService(self.browser)
        self.privacy_policy = PrivacyPolicy(self.browser)
        self.studio_home_page = DashboardPageExtended(self.browser)
        self.course_info = get_course_info()
        self.studio_course_outline = CourseOutlinePage(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])

        self.studio_home_page.visit()
    def setUp(self):
        super(PagesTestWithLms, self).setUp()

        self.course_info = get_course_info()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.pages_page = PagesPageExtended(
            self.browser,
            self.course_info['org'],
            self.course_info['number'],
            self.course_info['run']
        )
        self.pages_page.visit()
    def setUp(self):
        super(GradedProblemTest, self).setUp()

        login_api = LmsLoginApi()
        login_api.authenticate(self.browser)

        self.course_info = get_course_info()

        self.lms_courseware = CoursewarePageExtended(
            self.browser, get_course_key(self.course_info))

        self.import_page = ImportCoursePageExtended(*self.page_args())
        self.import_page.visit()
        self.import_page.upload_tarball(self.tarball_name)
        self.import_page.wait_for_upload()

        self.course_page = CourseHomePageExtended(
            self.browser, get_course_key(self.course_info))
        self.course_page.visit()
    def setUp(self):
        super(DashboardTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.studio_home_page = DashboardPageExtended(self.browser)
        self.course_info = get_course_info()
        self.studio_course_outline = CourseOutlinePageExtended(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
        self.lms_courseware = CoursewarePageExtended(
            self.browser, get_course_key(self.course_info))
        self.course_page = CourseHomePageExtended(self.browser,
                                                  get_course_info())
        self.dashboard_page = DashboardPageExtended(self.browser)

        self.dashboard_page.visit()
Exemple #20
0
    def setUp(self):
        super(PagesTestWithLms, self).setUp()

        self.course_info = get_course_info()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_page = CourseInfoPageExtended(
            self.browser, get_course_key(self.course_info))
        self.courseware_page = CoursewarePageExtended(
            self.browser, get_course_key(self.course_info))
        self.pages_page = PagesPageExtended(self.browser,
                                            self.course_info['org'],
                                            self.course_info['number'],
                                            self.course_info['run'])
        # Login to LMS to avoid authentication issue
        self.course_page.visit()
        self.pages_page.visit()
    def setUp(self):
        super(TextbookTest, self).setUp()

        studio_login = StudioLoginApi()
        studio_login.authenticate(self.browser)

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.lms_textbook = TextbookPage(self.browser)
        self.course_info = get_course_info()

        self.textbook_page = TextbookPageExtended(self.browser,
                                                  self.course_info['org'],
                                                  self.course_info['number'],
                                                  self.course_info['run'])

        self.textbook_page.visit()
        self.textbook_name = 'book_{}'.format(uuid4().hex)
        self.chapter_name = 'chap_1'
        # Add textbook
        self.add_textbook()
    def setUp(self):
        super(GradedProblemTest, self).setUp()

        login_api = LmsLoginApi()
        login_api.authenticate(self.browser)

        self.course_info = get_course_info()

        self.lms_courseware = CoursewarePageExtended(
            self.browser,
            get_course_key(self.course_info)
        )

        self.import_page = ImportCoursePageExtended(*self.page_args())
        self.import_page.visit()
        self.import_page.upload_tarball(self.tarball_name)
        self.import_page.wait_for_upload()

        self.course_page = CourseHomePageExtended(
            self.browser,
            get_course_key(self.course_info)
        )
        self.course_page.visit()
Exemple #23
0
    def setUp(self):
        """
        Initialize the page object
        """
        super(StudioGradingTest, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()
        self.grading_page = GradingPageExtended(
            self.browser,
            self.course_info['org'],
            self.course_info['number'],
            self.course_info['run'])

        self.studio_course_outline = CourseOutlinePageExtended(
            self.browser,
            self.course_info['org'],
            self.course_info['number'],
            self.course_info['run'])

        self.grading_page.visit()
Exemple #24
0
    def setUp(self):
        super(ScheduleAndDetailsLinks, self).setUp()

        lms_login = LmsLoginApi()
        lms_login.authenticate(self.browser)

        self.course_info = get_course_info()

        self.settings_page = SettingsPageExtended(self.browser,
                                                  self.course_info['org'],
                                                  self.course_info['number'],
                                                  self.course_info['run'])

        self.grading_page = GradingPageExtended(self.browser,
                                                self.course_info['org'],
                                                self.course_info['number'],
                                                self.course_info['run'])
        self.group_configuration = GroupConfigurationsPage(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
        self.advanced_settings = AdvancedSettingsPage(
            self.browser, self.course_info['org'], self.course_info['number'],
            self.course_info['run'])
        self.course_team_page = UsersPageMixin(self.browser)
class EnterpriseTestBase(WebAppTest):
    """
    Test Enterprise Login
    """
    def setUp(self):
        """
        Initialize all page objects
        """
        super(EnterpriseTestBase, self).setUp()
        self.browser.maximize_window()
        self.ent_portal_login = EnterprisePortalLogin(self.browser)
        self.ent_portal_home = EnterprisePortalHome(self.browser)
        self.ent_portal_course_start = \
            EnterprisePortalCourseStart(self.browser)
        self.ent_portal_course_structure = \
            EnterprisePortalCourseStructure(self.browser)
        self.ent_course_enrollment = \
            EnterpriseCourseEnrollment(self.browser)
        self.ent_data_sharing_consent = \
            EnterpriseDataSharingConsentPage(self.browser)
        self.ecommerce_courses_page = \
            EcommerceCoursesPage(self.browser)
        self.lms_login = LmsLogin(self.browser)
        self.ent_edx_registration = EnterpriseEdxRegistration(self.browser)
        self.ent_edx_login = EnterpriseEdxLogin(self.browser)
        self.dashboard = DashboardPageExtended(self.browser)
        self.courses_page = CoursesPage(self.browser)
        self.course_about_page = CourseAboutPageExtended(self.browser)
        self.track_selection_page = TrackSelectionPage(self.browser)
        self.user_account = UserAccountSettings(self.browser)
        self.cyber_source_page = CyberSourcePage(self.browser)
        self.single_seat_basket = SingleSeatBasketPage(self.browser)
        self.receipt_page = ReceiptPage(self.browser)
        self.lms_api_client = LmsApiClient()
        self.login_api = LmsLoginApi()
        self.logout_api = LogoutApi()

    def unlink_account(self):
        """
        Unlink IDP Account
        This serves as a fixture for unlinked user test case, it unlinks the
        user after running the tests to make sure that the precondition
        of test is true
        """
        # Visit account setting page
        self.user_account.visit()
        self.user_account.switch_account_settings_tabs('accounts-tab')
        # If linked account is found, unlink it
        if self.user_account.is_idp_account_linked(IDP_CSS_ID):
            self.user_account.unlink_idp_account(IDP_CSS_ID)
        # Logout using api
        self.logout_from_lms_using_api()

    def login_to_ent_portal(self, ent_portal_username, ent_portal_password):
        """
        Login to enterprise portal and find the course and click on it
        """
        # Open portal
        self.ent_portal_login.visit()
        # Login
        self.ent_portal_login.login_to_portal(ent_portal_username,
                                              ent_portal_password)
        self.ent_portal_home.wait_for_page()

    def access_course(self):
        """
        Access the course from portal
        """
        # Open the course pop up and look for the desired course
        self.ent_portal_home.open_courses_popup()
        course_titles = self.ent_portal_home.fetch_course_titles_list()
        self.assert_(ENT_COURSE_TITLE in course_title
                     for course_title in course_titles)
        # Go to course page and then use the link there to go to edX
        self.ent_portal_home.open_enterprise_course_page(ENT_COURSE_TITLE)
        self.ent_portal_course_start.wait_for_page()
        self.ent_portal_course_start.start_or_continue_course()
        self.ent_portal_course_structure.wait_for_page()
        self.ent_portal_course_structure.open_course_on_edx()
        # Get handle of newly opened edx window and switch control to it
        edx_window = self.driver.window_handles[1]
        self.driver.switch_to_window(edx_window)

    def login_ent_edx_user(self):
        """
        Login the user using edX customized logistration page
        """

        # edx credentials
        self.ent_edx_login.wait_for_page()
        self.assertEqual(ENTERPRISE_NAME,
                         self.ent_edx_login.get_enterprise_name())
        self.ent_edx_login.login(LOGIN_EMAIL, LOGIN_PASSWORD)

    def register_ent_edx_user(self):
        """
        Register the enterprise user using edX customized logistration page
        """
        __, email = get_random_credentials()
        self.ent_edx_registration.visit()
        self.assertEqual(ENTERPRISE_NAME,
                         self.ent_edx_registration.get_enterprise_name())
        self.ent_edx_registration.register(email=email,
                                           full_name='Enterprise Test User',
                                           country="US")

    def logout_from_lms_using_api(self):
        """
        Get cookies from browser and send these cookie to python request to
        logout using api
        """

        self.logout_api.logout_url = '{}://{}/{}'.format(
            LMS_PROTOCOL, LMS_BASE_URL, 'logout')
        self.logout_api.cookies = self.browser.get_cookies()
        self.logout_api.logout()

    def login_user_lms_using_api(self):
        """
        Login user to LMS using login API
        """

        self.login_api.authenticate(self.browser)

    def login_and_go_to_course_enrollment_page(self):
        """
        Flow which covers the user login on enterprise portal, selecting the
        course and then login to edx course enrollment page
        """
        # The edX site is visited just to make sure that when user jumps to
        # edX from portal we don't have to handle authentication popup
        self.lms_login.visit()
        # Enterprise portal flow
        self.login_to_ent_portal(ENT_PORTAL_USERNAME, ENT_PORTAL_PASSWORD)
        self.access_course()
        self.login_ent_edx_user()
        # Verify that user is on course enrollment page
        self.ent_course_enrollment.wait_for_page()

    def register_and_go_to_course_enrollment_page(self):
        """
        Flow which covers the user login on enterprise portal, selecting the
        course and then register to edx course enrollment page
        """
        # The edX site is visited just to make sure that when user jumps to
        # edX from portal we don't have to handle authentication popup
        self.lms_login.visit()
        # Enterprise portal flow
        self.login_to_ent_portal(ENT_PORTAL_USERNAME, ENT_PORTAL_PASSWORD)
        self.access_course()
        self.ent_edx_login.wait_for_page()
        self.register_ent_edx_user()
        # Verify that user is on course enrollment page
        self.ent_course_enrollment.wait_for_page()

    def payment_using_cyber_source(self):
        """
        Make payment for course by providing Billing Info and Payment details
        in respected areas.
        """
        self.cyber_source_page.set_card_holder_info(CARD_HOLDER_INFO)
        self.cyber_source_page.set_billing_info(BILLING_INFO)
        self.cyber_source_page.click_payment_button()
        self.receipt_page.wait_for_page()

    def register_edx_user(self):
        """
        Register the user using edX registration page
        """
        username, email = get_random_credentials()
        self.ent_edx_registration.visit()
        self.ent_edx_registration.register(email=email,
                                           full_name='Test User',
                                           username=username,
                                           password='******',
                                           country="US")
        self.dashboard.wait_for_page()

    def verify_info_is_populated_on_basket(self, discounted_price):
        """
        After User accept data sharing consent from landing pag
        verify that following information is
        displayed correctly on basket page:
        i) Enterprise offer is applied
        ii) Discounted amount

        Arguments:
            discounted_price(float): Discounted price of the course.
        """
        self.assertTrue(self.single_seat_basket.is_offer_applied())
        self.assertEqual(self.single_seat_basket.total_price_after_discount,
                         discounted_price)
        self.payment_using_cyber_source()

    def verify_receipt_info_for_discounted_course(self):
        """
        Verify that info on receipt page is correct.

        Verify
        i) Course title.
        ii) Order date
        """
        self.assertIn(ENT_COURSE_TITLE, self.receipt_page.order_desc)
        self.assertEqual(datetime.utcnow().strftime("%Y-%m-%d"),
                         self.receipt_page.order_date)
Exemple #26
0
class EnterpriseTestBase(WebAppTest):
    """
    Test Enterprise Login
    """

    def setUp(self):
        """
        Initialize all page objects
        """
        super(EnterpriseTestBase, self).setUp()
        self.browser.maximize_window()
        self.ent_portal_login = EnterprisePortalLogin(self.browser)
        self.ent_portal_home = EnterprisePortalHome(self.browser)
        self.ent_portal_course_start = \
            EnterprisePortalCourseStart(self.browser)
        self.ent_portal_course_structure = \
            EnterprisePortalCourseStructure(self.browser)
        self.ent_course_enrollment = \
            EnterpriseCourseEnrollment(self.browser)
        self.ent_data_sharing_consent = \
            EnterpriseDataSharingConsentPage(self.browser)
        self.ecommerce_courses_page = \
            EcommerceCoursesPage(self.browser)
        self.lms_login = LmsLogin(self.browser)
        self.ent_edx_registration = EnterpriseEdxRegistration(self.browser)
        self.ent_edx_login = EnterpriseEdxLogin(self.browser)
        self.dashboard = DashboardPageExtended(self.browser)
        self.courses_page = CoursesPage(self.browser)
        self.course_about_page = CourseAboutPageExtended(self.browser)
        self.track_selection_page = TrackSelectionPage(self.browser)
        self.user_account = UserAccountSettings(self.browser)
        self.cyber_source_page = CyberSourcePage(self.browser)
        self.single_seat_basket = SingleSeatBasketPage(self.browser)
        self.receipt_page = ReceiptPage(self.browser)
        self.lms_api_client = LmsApiClient()
        self.login_api = LmsLoginApi()
        self.logout_api = LogoutApi()

    def unlink_account(self):
        """
        Unlink IDP Account
        This serves as a fixture for unlinked user test case, it unlinks the
        user after running the tests to make sure that the precondition
        of test is true
        """
        # Visit account setting page
        self.user_account.visit()
        self.user_account.switch_account_settings_tabs('accounts-tab')
        # If linked account is found, unlink it
        if self.user_account.is_idp_account_linked(IDP_CSS_ID):
            self.user_account.unlink_idp_account(IDP_CSS_ID)
        # Logout using api
        self.logout_from_lms_using_api()

    def add_recovery_email(self, email):
        """
        Add secondary email address for enterprise learner
        """
        self.user_account.visit()
        self.user_account.fill_secondary_email_field(email)

    def login_to_ent_portal(self, ent_portal_username, ent_portal_password):
        """
        Login to enterprise portal and find the course and click on it
        """
        # Open portal
        self.ent_portal_login.visit()
        # Login
        self.ent_portal_login.login_to_portal(
            ent_portal_username,
            ent_portal_password)
        self.ent_portal_home.wait_for_page()

    def access_course(self):
        """
        Access the course from portal
        """
        # Open the course pop up and look for the desired course
        self.ent_portal_home.open_courses_popup()
        course_titles = self.ent_portal_home.fetch_course_titles_list()
        self.assert_(
            ENT_COURSE_TITLE in course_title
            for course_title in course_titles
        )
        # Go to course page and then use the link there to go to edX
        self.ent_portal_home.open_enterprise_course_page(
            ENT_COURSE_TITLE
        )
        self.ent_portal_course_start.wait_for_page()
        self.ent_portal_course_start.start_or_continue_course()
        self.ent_portal_course_structure.wait_for_page()
        self.ent_portal_course_structure.open_course_on_edx()
        # Get handle of newly opened edx window and switch control to it
        edx_window = self.driver.window_handles[1]
        self.driver.switch_to_window(edx_window)

    def login_ent_edx_user(self):
        """
        Login the user using edX customized logistration page
        """

        # edx credentials
        self.ent_edx_login.wait_for_page()
        self.assertEqual(
            ENTERPRISE_NAME,
            self.ent_edx_login.get_enterprise_name()
        )
        self.ent_edx_login.login(
            LOGIN_EMAIL,
            LOGIN_PASSWORD
        )

    def register_ent_edx_user(self):
        """
        Register the enterprise user using edX customized logistration page
        """
        __, email = get_random_credentials()
        self.ent_edx_registration.visit()
        self.assertEqual(
            ENTERPRISE_NAME,
            self.ent_edx_registration.get_enterprise_name()
        )
        self.ent_edx_registration.register(
            email=email,
            full_name='Enterprise Test User',
            country="US"
        )

    def logout_from_lms_using_api(self):
        """
        Get cookies from browser and send these cookie to python request to
        logout using api
        """

        self.logout_api.logout_url = '{}://{}/{}'.format(
            LMS_PROTOCOL,
            LMS_BASE_URL,
            'logout'
            )
        self.logout_api.cookies = self.browser.get_cookies()
        self.logout_api.logout()

    def login_user_lms_using_api(self):
        """
        Login user to LMS using login API
        """

        self.login_api.authenticate(self.browser)

    def login_and_go_to_course_enrollment_page(self):
        """
        Flow which covers the user login on enterprise portal, selecting the
        course and then login to edx course enrollment page
        """
        # The edX site is visited just to make sure that when user jumps to
        # edX from portal we don't have to handle authentication popup
        self.lms_login.visit()
        # Enterprise portal flow
        self.login_to_ent_portal(
            ENT_PORTAL_USERNAME,
            ENT_PORTAL_PASSWORD)
        self.access_course()
        self.login_ent_edx_user()
        # Verify that user is on course enrollment page
        self.ent_course_enrollment.wait_for_page()

    def register_and_go_to_course_enrollment_page(self):
        """
        Flow which covers the user login on enterprise portal, selecting the
        course and then register to edx course enrollment page
        """
        # The edX site is visited just to make sure that when user jumps to
        # edX from portal we don't have to handle authentication popup
        self.lms_login.visit()
        # Enterprise portal flow
        self.login_to_ent_portal(
            ENT_PORTAL_USERNAME,
            ENT_PORTAL_PASSWORD)
        self.access_course()
        self.ent_edx_login.wait_for_page()
        self.register_ent_edx_user()
        # Verify that user is on course enrollment page
        self.ent_course_enrollment.wait_for_page()

    def payment_using_cyber_source(self):
        """
        Make payment for course by providing Billing Info and Payment details
        in respected areas.
        """
        self.cyber_source_page.set_card_holder_info(CARD_HOLDER_INFO)
        self.cyber_source_page.set_billing_info(BILLING_INFO)
        self.cyber_source_page.click_payment_button()
        self.receipt_page.wait_for_page()

    def register_edx_user(self):
        """
        Register the user using edX registration page
        """
        username, email = get_random_credentials()
        self.ent_edx_registration.visit()
        self.ent_edx_registration.register(
            email=email,
            full_name='Test User',
            username=username,
            password='******',
            country="US"
        )
        self.dashboard.wait_for_page()

    def verify_info_is_populated_on_basket(self, discounted_price):
        """
        After User accept data sharing consent from landing pag
        verify that following information is
        displayed correctly on basket page:
        i) Enterprise offer is applied
        ii) Discounted amount

        Arguments:
            discounted_price(float): Discounted price of the course.
        """
        self.assertTrue(self.single_seat_basket.is_offer_applied())
        self.assertEqual(
            self.single_seat_basket.total_price_after_discount,
            discounted_price
        )
        self.payment_using_cyber_source()

    def verify_receipt_info_for_discounted_course(self):
        """
        Verify that info on receipt page is correct.

        Verify
        i) Course title.
        ii) Order date
        """
        self.assertIn(ENT_COURSE_TITLE, self.receipt_page.order_desc)
        self.assertEqual(
            datetime.utcnow().strftime("%Y-%m-%d"),
            self.receipt_page.order_date
        )