Test fixes to prepare for firefox upgrade on jenkins

This commit is contained in:
Stuart Young
2018-01-25 13:15:44 -05:00
committed by Michael Youngstrom
parent 81899bdaee
commit 53fe34615e
27 changed files with 158 additions and 50 deletions

View File

@@ -8,6 +8,7 @@ from bok_choy.promise import EmptyPromise, Promise
from common.test.acceptance.pages.common.utils import click_css, confirm_prompt
from common.test.acceptance.pages.studio import BASE_URL
from common.test.acceptance.pages.studio.utils import HelpMixin, type_in_codemirror
from common.test.acceptance.tests.helpers import click_and_wait_for_window
class ContainerPage(PageObject, HelpMixin):
@@ -177,6 +178,7 @@ class ContainerPage(PageObject, HelpMixin):
"""
Returns the link for publishing a unit.
"""
self.scroll_to_element('.action-publish')
return self.q(css='.action-publish').first
def publish(self):
@@ -224,7 +226,7 @@ class ContainerPage(PageObject, HelpMixin):
Switches the browser to the newly opened LMS window.
"""
self.q(css='.button-view').first.click()
click_and_wait_for_window(self, self.q(css='.button-view').first)
self._switch_to_lms()
def verify_publish_title(self, expected_title):

View File

@@ -291,7 +291,7 @@ class ImportMixin(ImportExportMixin):
self.q(css='input[type="file"]')[0].send_keys(asset_file_path)
# Some of the tests need these lines to pass so don't remove them.
self._wait_for_button()
click_css(self, '.submit-button', require_notification=False)
click_css(self, '.submit-button', require_notification=True)
def is_upload_finished(self):
"""

View File

@@ -83,6 +83,13 @@ class DashboardPage(PageObject, HelpMixin):
# Clicking on course with run will trigger an ajax event
self.wait_for_ajax()
def scroll_to_course(self, course_key):
"""
Scroll down to the course element
"""
element = '[data-course-key*="{}"]'.format(course_key)
self.scroll_to_element(element)
def has_new_library_button(self):
"""
(bool) is the "New Library" button present?
@@ -239,16 +246,18 @@ class DashboardPage(PageObject, HelpMixin):
Click the tab to display the available libraries, and return detail of them.
"""
# Workaround Selenium/Firefox bug: `.text` property is broken on invisible elements
self.q(css='#course-index-tabs .libraries-tab a').click()
library_tab_css = '#course-index-tabs .libraries-tab'
self.wait_for_element_presence(library_tab_css, "Libraries tab")
self.q(css=library_tab_css).click()
if self.q(css='.list-notices.libraries-tab').present:
# No libraries are available.
self.wait_for_element_visibility('.libraries-tab .new-library-button', "Switch to library tab")
self.wait_for_element_presence('.libraries-tab .new-library-button', "new library tab")
return []
div2info = lambda element: {
'name': element.find_element_by_css_selector('.course-title').text,
'link_element': element.find_element_by_css_selector('.course-title'),
'org': element.find_element_by_css_selector('.course-org .value').text,
'number': element.find_element_by_css_selector('.course-num .value').text,
'link_element': element.find_element_by_css_selector('a.library-link'),
'url': element.find_element_by_css_selector('a.library-link').get_attribute('href'),
}
self.wait_for_element_visibility('.libraries li.course-item', "Switch to library tab")

View File

@@ -290,13 +290,17 @@ class CourseOutlineContainer(CourseOutlineItem):
self.wait_for_element_presence(
self._bounded_selector(self.ADD_BUTTON_SELECTOR), 'Toggle control is present'
)
add_button = self.q(css=self._bounded_selector(self.ADD_BUTTON_SELECTOR)).first.results
css_element = self._bounded_selector(self.ADD_BUTTON_SELECTOR)
add_button = self.q(css=css_element).first.results # pylint: disable=no-member
self.scroll_to_element(css_element) # pylint: disable=no-member
return add_button and add_button[0].is_displayed()
currently_expanded = subsection_expanded()
# Need to click slightly off-center in order for the click to be recognized.
ele = self.browser.find_element_by_css_selector(self._bounded_selector('.ui-toggle-expansion .fa'))
css_element = self._bounded_selector('.ui-toggle-expansion .fa')
self.scroll_to_element(css_element) # pylint: disable=no-member
ele = self.browser.find_element_by_css_selector(css_element) # pylint: disable=no-member
ActionChains(self.browser).move_to_element_with_offset(ele, 8, 8).click().perform() # pylint: disable=no-member
self.wait_for_element_presence(self._bounded_selector(self.ADD_BUTTON_SELECTOR), 'Subsection is expanded')
@@ -314,7 +318,9 @@ class CourseOutlineContainer(CourseOutlineItem):
"""
Return whether this outline item is currently collapsed.
"""
return "is-collapsed" in self.q(css=self._bounded_selector('')).first.attrs("class")[0] # pylint: disable=no-member
css_element = self._bounded_selector('')
self.scroll_to_element(css_element) # pylint: disable=no-member
return "is-collapsed" in self.q(css=css_element).first.attrs("class")[0] # pylint: disable=no-member
class CourseOutlineChild(PageObject, CourseOutlineItem):

View File

@@ -260,18 +260,21 @@ class SettingsPage(CoursePage):
Set the entrance exam requirement via the checkbox.
"""
checkbox = self.entrance_exam_field
# Wait for license section to load before interacting with the checkbox to avoid race condition
self.wait_for_element_presence('div.wrapper-license', 'License section present')
selected = checkbox.is_selected()
self.scroll_to_element('#entrance-exam-enabled')
if required and not selected:
checkbox.click()
self.wait_for_element_visibility(
self.wait_for_element_presence(
'#entrance-exam-minimum-score-pct',
'Entrance exam minimum score percent is visible'
'Entrance exam minimum score percent is present'
)
if not required and selected:
checkbox.click()
self.wait_for_element_invisibility(
self.wait_for_element_absence(
'#entrance-exam-minimum-score-pct',
'Entrance exam minimum score percent is invisible'
'Entrance exam minimum score percent is absent'
)
def save_changes(self, wait_for_confirmation=True):

View File

@@ -7,6 +7,7 @@ from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from common.test.acceptance.pages.common.utils import click_css, sync_on_notification
from common.test.acceptance.tests.helpers import click_and_wait_for_window
NAV_HELP_NOT_SIGNED_IN_CSS = '.nav-item.nav-not-signedin-help a'
NAV_HELP_CSS = '.nav-item.nav-account-help a'
@@ -288,8 +289,9 @@ class HelpMixin(object):
else:
element_css = NAV_HELP_NOT_SIGNED_IN_CSS
self.q(css=element_css).first.click()
return self.q(css=element_css).results[0]
help_element = self.q(css=element_css).results[0]
click_and_wait_for_window(self, help_element)
return help_element
def get_side_bar_help_element_and_click_help(self, as_list_item=False, index=-1):
"""
@@ -313,5 +315,5 @@ class HelpMixin(object):
element_css = SIDE_BAR_HELP_CSS
help_element = self.q(css=element_css).results[index]
help_element.click()
click_and_wait_for_window(self, help_element)
return help_element

View File

@@ -50,6 +50,10 @@ BUTTON_SELECTORS = {
'collapse_link': '.collapse-action.collapse-setting',
}
DROP_DOWN_SELECTORS = {
'transcript_language': '.wrapper-translations-settings .list-settings .list-settings-item select'
}
DISPLAY_NAME = "Component Display Name"
DEFAULT_SETTINGS = [
@@ -160,11 +164,48 @@ class VideoComponentPage(VideoPage):
index (int): query index
"""
self.scroll_to_button(button_name, index)
self.q(css=BUTTON_SELECTORS[button_name]).nth(index).click()
if require_notification:
sync_on_notification(self)
self.wait_for_ajax()
def scroll_to_button(self, button_name, index=0):
"""
Scroll to a button specified by `button_name`
Arguments:
button_name (str): button name
index (int): query index
"""
element = self.q(css=BUTTON_SELECTORS[button_name])[index]
self.browser.execute_script("arguments[0].scrollIntoView();", element)
def get_drop_down_items(self, drop_down_name, index=0):
"""
Get the items from a drop down list specified by `drop_down_name`
Arguments:
drop_down_name (str): name of the drop down list
index (int): query index
"""
drop_downs = self.q(css=DROP_DOWN_SELECTORS[drop_down_name])
return drop_downs[index].find_elements_by_tag_name("option")
def is_language_disabled(self, lang_code):
"""
Determine whether or not a lanuage is disabled in a drop down
Arguments:
lang_code (str): two letter language code
"""
language_options = self.get_drop_down_items('transcript_language', index=1)
language = [l for l in language_options if l.get_attribute('value') == lang_code][0]
return language.get_attribute("disabled")
@staticmethod
def file_path(filename):
"""
@@ -197,6 +238,7 @@ class VideoComponentPage(VideoPage):
"""
asset_file_path = self.file_path(asset_filename)
self.scroll_to_button('upload_asset')
self.click_button('upload_asset', index)
self.q(css=CLASS_SELECTORS['attach_asset']).results[0].send_keys(asset_file_path)
# Only srt format transcript files can be uploaded, If an error