Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
chore: automate discussions, handouts and announcements tabs
Browse files Browse the repository at this point in the history
Fixes: LEARNER-9393
  • Loading branch information
bilalawan321 committed Aug 18, 2023
1 parent c5dd957 commit df3362c
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 124 deletions.
2 changes: 2 additions & 0 deletions tests/android/pages/android_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion tests/android/pages/android_main_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
22 changes: 11 additions & 11 deletions tests/android/tests/test_android_course_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down
152 changes: 51 additions & 101 deletions tests/android/tests/test_android_course_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,143 +21,92 @@ 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 "<course name>" 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)
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)

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')
46 changes: 35 additions & 11 deletions tests/android/tests/test_android_discussions_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down Expand Up @@ -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()
Expand All @@ -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')

0 comments on commit df3362c

Please sign in to comment.