diff --git a/tests/android/pages/android_elements.py b/tests/android/pages/android_elements.py index 6f7ba156..235565c0 100644 --- a/tests/android/pages/android_elements.py +++ b/tests/android/pages/android_elements.py @@ -151,6 +151,7 @@ course_dashboard_course_title = 'org.edx.mobile:id/course_title' course_dashboard_course_expiry_date = 'org.edx.mobile:id/course_expiry_date' course_dashboard_upgrade_button = 'org.edx.mobile:id/btn_upgrade' +course_dashboard_tabs = 'org.edx.mobile:id/tabs' # COURSE SUBSECTION SCREEN course_dashboard_row_header = 'org.edx.mobile:id/row_header' @@ -225,6 +226,7 @@ course_resources_row_title = 'org.edx.mobile:id/row_title' course_resources_row_subtitle = 'org.edx.mobile:id/row_subtitle' course_resources_row_icon_type = 'org.edx.mobile:id/row_type' +course_handouts_webview_element = 'org.edx.mobile:id/content_error_root' # PROFILE OPTIONS SCREEN profile_options_wifi_switch = 'org.edx.mobile:id/switch_wifi' diff --git a/tests/android/pages/android_main_dashboard.py b/tests/android/pages/android_main_dashboard.py index d6729ad9..054e6dcb 100644 --- a/tests/android/pages/android_main_dashboard.py +++ b/tests/android/pages/android_main_dashboard.py @@ -4,7 +4,6 @@ from tests.android.pages import android_elements from tests.android.pages.android_base_page import AndroidBasePage -from tests.common import strings class AndroidMainDashboard(AndroidBasePage): diff --git a/tests/android/tests/test_android_course_dashboard.py b/tests/android/tests/test_android_course_dashboard.py index b41df64c..50e71b06 100644 --- a/tests/android/tests/test_android_course_dashboard.py +++ b/tests/android/tests/test_android_course_dashboard.py @@ -55,11 +55,11 @@ def test_ui_elements_smoke(self, set_capabilities, setup_logging): == strings.LOGIN_EDX_LOGO assert android_course_dashboard_page.course_dashboard_course_expiry_date().text - home_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[3] - videos_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[4] - discussions_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[5] - dates_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[6] - handouts_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[7] + home_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[4] + videos_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[5] + discussions_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[6] + dates_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[7] + handouts_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[8] assert home_tab.get_attribute('content-desc') == 'Home' assert home_tab.get_attribute('selected') == 'true' @@ -89,11 +89,11 @@ def test_load_contents_smoke(self, set_capabilities, setup_logging): """ android_course_dashboard_page = AndroidCourseDashboard(set_capabilities, setup_logging) - home_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[3] - videos_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[4] - discussions_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[5] - dates_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[6] - handouts_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[7] + home_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[4] + videos_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[5] + discussions_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[6] + dates_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[7] + handouts_tab = android_course_dashboard_page.course_dashboard_get_all_tabs()[8] videos_tab.click() assert videos_tab.get_attribute('selected') == 'true' @@ -111,7 +111,7 @@ def test_load_contents_smoke(self, set_capabilities, setup_logging): assert handouts_tab.get_attribute('selected') == 'true' assert handouts_tab.get_attribute('content-desc') == 'Handouts' - announcements_tabs = android_course_dashboard_page.course_dashboard_get_all_tabs()[7] + announcements_tabs = android_course_dashboard_page.course_dashboard_get_all_tabs()[8] announcements_tabs.click() assert announcements_tabs.get_attribute('selected') == 'true' assert announcements_tabs.get_attribute('content-desc') == 'Announcements' diff --git a/tests/android/tests/test_android_course_resources.py b/tests/android/tests/test_android_course_resources.py index 34f3b8ab..9bff358b 100644 --- a/tests/android/tests/test_android_course_resources.py +++ b/tests/android/tests/test_android_course_resources.py @@ -2,6 +2,7 @@ Course Resources Test Module """ +from appium.webdriver.common.mobileby import MobileBy from tests.android.pages import android_elements from tests.android.pages.android_course_dashboard import AndroidCourseDashboard from tests.android.pages.android_login_smoke import AndroidLoginSmoke @@ -20,8 +21,15 @@ class TestAndroidCourseResources(AndroidLoginSmoke): def test_ui_elements_smoke(self, set_capabilities, setup_logging): """ Scenarios: - Verify that Course Resources tab will show Back icon, - Verify that user should be able to go back by clicking Back icon + Verify that Course Dashboard tab will show following contents, + Header contents, + Back icon, + Specific "" as Title, Share icon, Course, + Verify that user should be able to go back by clicking Back icon + Verify that user should be able to view these Course contents: + Course Image, Course Name, Course Provider, Course Ending date, + Last accessed(if any), Course Content, + Verify all screen contents have their default values """ global_contents = Globals(setup_logging) @@ -29,134 +37,76 @@ def test_ui_elements_smoke(self, set_capabilities, setup_logging): android_my_courses_list_page = AndroidMyCoursesList(set_capabilities, setup_logging) android_main_dashboard_page = AndroidMainDashboard(set_capabilities, setup_logging) - assert android_main_dashboard_page.load_courses_tab() if android_my_courses_list_page.get_my_courses_list_row(): + course_name = android_my_courses_list_page.get_second_course().text android_my_courses_list_page.get_second_course().click() else: setup_logging.info('No course enrolled by this user.') - resources_tab_element = android_course_dashboard_page.get_resources_tab() - resources_tab_element.click() - assert resources_tab_element.get_attribute('selected') == 'true' - - navigation_icon = android_course_dashboard_page.get_navigation_icon() - assert navigation_icon.get_attribute('content-desc') == strings.COURSE_DASHBOARD_NAVIGATION_ICON - android_course_dashboard_page.get_navigation_icon().click() + assert android_course_dashboard_page.course_dashboard_toolbar_dismiss_button().get_attribute( + 'clickable') == strings.TRUE + android_course_dashboard_page.course_dashboard_toolbar_dismiss_button().click() assert android_main_dashboard_page.on_screen() == global_contents.MAIN_DASHBOARD_ACTIVITY_NAME - android_my_courses_list_page.load_course_details_screen() - android_course_dashboard_page.get_resources_tab().click() + android_my_courses_list_page.get_second_course().click() + + if course_name: + # Verifing the title of the screen + assert course_name in android_course_dashboard_page.course_dashboard_course_title().text + + assert android_course_dashboard_page.course_dashboard_course_organization().text \ + == strings.LOGIN_EDX_LOGO + assert android_course_dashboard_page.course_dashboard_course_expiry_date().text - def test_resources_tab_smoke(self, set_capabilities, setup_logging): + def test_handouts_tab_smoke(self, set_capabilities, setup_logging): """ Scenarios: - Verify that resources tab will selected after loading - Verify that Course Resources tab will show following contents, - Resources as Title, Share icon, + Verify that value of handouts tab is false by default + Verify that clicking handouts will set its value to true + Verify that webview is loaded after clicking handouts """ global_contents = Globals(setup_logging) - android_course_dashboard_page = AndroidCourseDashboard(set_capabilities, setup_logging) - resources_tab_element = android_course_dashboard_page.get_resources_tab() + scrollable_tab = set_capabilities.find_element(MobileBy.ID, android_elements.course_dashboard_tabs) + tab_elements = scrollable_tab.find_elements(MobileBy.CLASS_NAME, android_elements.course_layout) - assert resources_tab_element.get_attribute('selected') == 'true' - share_icon = android_course_dashboard_page.get_course_share_icon() - assert share_icon.get_attribute('content-desc') == strings.COURSE_DASHBOARD_SHARE_COURSE_ANDROID + handouts_tab = tab_elements[4] + assert handouts_tab.get_attribute('selected') == strings.FALSE + handouts_tab.click() + assert handouts_tab.get_attribute('selected') == strings.TRUE - resources_tab_title = global_contents.get_by_class_from_elements( - set_capabilities, - android_elements.all_textviews, - global_contents.first_existence) - assert resources_tab_title.text == strings.COURSE_DASHBOARD_RESOURCES_TAB + hanouts_page_element = global_contents.wait_and_get_element( + set_capabilities, android_elements.course_handouts_webview_element) + assert hanouts_page_element.get_attribute('displayed') == strings.TRUE + assert hanouts_page_element.get_attribute('enabled') == strings.TRUE - def test_handouts_smoke(self, set_capabilities, setup_logging): + def test_announcements_smoke(self, set_capabilities, setup_logging): """ Scenarios: - Verify that user should be able to view: - Handouts as Row title - Subtitle of the row, - Handouts icon in row, - Handouts can be clickable and it will navigate to handouts page - Handouts as Title of the page + Verify that value of handouts tab is false by default + Verify that clicking handouts will set its value to true + Verify that webview is loaded after clicking handouts """ global_contents = Globals(setup_logging) android_course_dashboard_page = AndroidCourseDashboard(set_capabilities, setup_logging) - handouts_row_title = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_title, - global_contents.first_existence) - assert handouts_row_title.text == strings.COURSE_DASHBOARD_HANDOUTS_TITLE - - handouts_row_subtitle = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_subtitle, - global_contents.first_existence) - assert handouts_row_subtitle.text == strings.COURSE_DASHBOARD_HANDOUTS_ROW - - handouts_icon_element = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_icon_type, - global_contents.first_existence) - assert handouts_icon_element.get_attribute('displayed') == 'true' - - handouts_row_title.click() - handouts_page_title = global_contents.get_by_class_from_elements( - set_capabilities, - android_elements.all_textviews, - global_contents.first_existence) - assert handouts_page_title.text == strings.COURSE_DASHBOARD_HANDOUTS_TITLE - - android_course_dashboard_page.get_navigation_icon().click() - - def test_announcement_smoke(self, set_capabilities, setup_logging): - """ - Scenarios: - Verify that user should be able to view: - Announcements as Row title - Subtitle of the row, - Announcements icon in row, - Announcements can be clickable and it will navigate to Announcements page - Announcements as Title of page - """ - global_contents = Globals(setup_logging) - - announcement_row_title = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_title, - global_contents.second_existence) - assert announcement_row_title.text == strings.COURSE_DASHBOARD_ANNOUNCEMENT_TITLE - - announcement_row_subtitle = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_subtitle, - global_contents.second_existence) - assert announcement_row_subtitle.text == strings.COURSE_DASHBOARD_ANNOUNCEMENT_ROW - - announcement_icon_element = global_contents.get_by_id_from_elements( - set_capabilities, - android_elements.course_resources_row_icon_type, - global_contents.second_existence) - assert announcement_icon_element.get_attribute('displayed') == 'true' - - announcement_row_title.click() - announcement_page_title = global_contents.get_by_class_from_elements( - set_capabilities, - android_elements.all_textviews, - global_contents.first_existence) - assert announcement_page_title.text == strings.COURSE_DASHBOARD_ANNOUNCEMENT_TITLE + announcements_tabs = android_course_dashboard_page.course_dashboard_get_all_tabs()[8] + announcements_tabs.click() + announcements_webview_element = global_contents.wait_and_get_element( + set_capabilities, android_elements.course_handouts_webview_element) + assert announcements_webview_element.get_attribute('enabled') == strings.TRUE def test_sign_out_smoke(self, set_capabilities, setup_logging): """ Scenarios: - Verify that user can logout from course resources screen + Verify that user can logout from course dashboard screen """ android_main_dashboard_page = AndroidMainDashboard(set_capabilities, setup_logging) - android_course_dashboard_page = AndroidCourseDashboard(set_capabilities, setup_logging) - android_course_dashboard_page.get_navigation_icon().click() - set_capabilities.back() - assert android_main_dashboard_page.get_logout_account_option().text == strings.PROFILE_OPTIONS_SIGNOUT_BUTTON + profile_tab = android_main_dashboard_page.get_all_tabs()[2] + assert profile_tab.text == 'Profile' + profile_tab.click() + assert android_main_dashboard_page.log_out() == Globals.DISCOVERY_LAUNCH_ACTIVITY_NAME setup_logging.info('Ending Test Case') diff --git a/tests/android/tests/test_android_discussions_dashboard.py b/tests/android/tests/test_android_discussions_dashboard.py index 6455ed8c..be345668 100644 --- a/tests/android/tests/test_android_discussions_dashboard.py +++ b/tests/android/tests/test_android_discussions_dashboard.py @@ -2,6 +2,7 @@ Course Discussions Dashboard Test Module """ +from appium.webdriver.common.mobileby import MobileBy from tests.android.pages import android_elements from tests.android.pages.android_course_dashboard import AndroidCourseDashboard from tests.android.pages.android_discussions_dashboard import \ @@ -39,18 +40,38 @@ def test_ui_elements_smoke(self, set_capabilities, setup_logging): android_my_courses_list_page = AndroidMyCoursesList(set_capabilities, setup_logging) android_main_dashboard_page = AndroidMainDashboard(set_capabilities, setup_logging) - assert android_main_dashboard_page.load_courses_tab() + global_contents = Globals(setup_logging) + android_course_dashboard_page = AndroidCourseDashboard(set_capabilities, setup_logging) + android_my_courses_list_page = AndroidMyCoursesList(set_capabilities, setup_logging) + android_main_dashboard_page = AndroidMainDashboard(set_capabilities, setup_logging) + if android_my_courses_list_page.get_my_courses_list_row(): - android_my_courses_list_page.get_first_course().click() + course_name = android_my_courses_list_page.get_second_course().text + android_my_courses_list_page.get_second_course().click() else: setup_logging.info('No course enrolled by this user.') - navigation_icon = android_course_dashboard_page.get_navigation_icon() - assert navigation_icon.get_attribute('content-desc') == strings.COURSE_DASHBOARD_NAVIGATION_ICON + assert android_course_dashboard_page.course_dashboard_toolbar_dismiss_button().get_attribute( + 'clickable') == strings.TRUE + android_course_dashboard_page.course_dashboard_toolbar_dismiss_button().click() + assert android_main_dashboard_page.on_screen() == global_contents.MAIN_DASHBOARD_ACTIVITY_NAME + android_my_courses_list_page.get_second_course().click() - discussion_tab_element = android_course_dashboard_page.get_discussion_tab() - discussion_tab_element.click() - assert discussion_tab_element.get_attribute('selected') == 'true' + if course_name: + # Verifing the title of the screen + assert course_name in android_course_dashboard_page.course_dashboard_course_title().text + + assert android_course_dashboard_page.course_dashboard_course_organization().text \ + == strings.LOGIN_EDX_LOGO + assert android_course_dashboard_page.course_dashboard_course_expiry_date().text + + scrollable_tab = set_capabilities.find_element(MobileBy.ID, android_elements.course_dashboard_tabs) + tab_elements = scrollable_tab.find_elements(MobileBy.CLASS_NAME, android_elements.course_layout) + + discussion_tab = tab_elements[2] + assert discussion_tab.get_attribute('selected') == strings.FALSE + discussion_tab.click() + assert discussion_tab.get_attribute('selected') == strings.TRUE assert global_contents.get_element_by_id( set_capabilities, @@ -71,7 +92,7 @@ def test_ui_elements_smoke(self, set_capabilities, setup_logging): general_posts_element = global_contents.get_by_id_from_elements( set_capabilities, android_elements.discussion_all_posts_button, - global_contents.fourth_existence) + global_contents.third_existence) assert general_posts_element.text == strings.DISCUSSION_GENERAL_POSTS def test_load_contents_smoke(self, set_capabilities, setup_logging): @@ -105,7 +126,7 @@ def test_load_contents_smoke(self, set_capabilities, setup_logging): general_posts_element = global_contents.get_by_id_from_elements( set_capabilities, android_elements.discussion_all_posts_button, - global_contents.fourth_existence) + global_contents.third_existence) general_posts_element.click() assert discussions_dashboard_page.get_screen_title().text == strings.DISCUSSION_GENERAL_POSTS discussions_dashboard_page.get_navigation_icon().click() @@ -123,7 +144,10 @@ def test_sign_out_smoke(self, set_capabilities, setup_logging): android_main_dashboard_page = AndroidMainDashboard(set_capabilities, setup_logging) discussions_dashboard_page.get_navigation_icon().click() - discussions_dashboard_page.get_navigation_icon().click() - assert android_main_dashboard_page.get_logout_account_option().text == strings.PROFILE_OPTIONS_SIGNOUT_BUTTON + set_capabilities.back() + profile_tab = android_main_dashboard_page.get_all_tabs()[2] + assert profile_tab.text == 'Profile' + profile_tab.click() + assert android_main_dashboard_page.log_out() == Globals.DISCOVERY_LAUNCH_ACTIVITY_NAME setup_logging.info('Ending Test Case')