def expand_subsection(self): """ Toggle the expansion of this subsection. """ disable_animations(self) def subsection_expanded(): """ Returns whether or not this subsection is expanded. """ self.wait_for_element_presence( self._bounded_selector(self.ADD_BUTTON_SELECTOR), 'Toggle control is present' ) 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. 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), u'Subsection is expanded') EmptyPromise( lambda: subsection_expanded() != currently_expanded, u"Check that the container {} has been toggled".format(self.locator) ).fulfill() enable_animations(self) return self
def click_create_certificate_button(self): """ Create a new certificate. """ disable_animations(self) self.find_css('.action-primary').first.click() self.wait_for_ajax()
def add_word_cloud_component(self, publish=False): """ Clicks Advanced button in Add New Component then Clicks Word Cloud and verifies that it appears on Studio """ add_x_block_button_css = '.add-xblock-component-button' \ '[data-type="advanced"]' word_cloud_button_css = '.button-component[data-category="word_cloud"]' self.wait_for_element_visibility( add_x_block_button_css, 'Add xblock button is visible.' ) disable_animations(self) self.q(css=add_x_block_button_css).click() self.wait_for_element_visibility( word_cloud_button_css, 'Word cloud button is visible.' ) self.q(css=word_cloud_button_css).click() # Click initiates an ajax call self.wait_for_ajax() self.wait_for_element_visibility( '.xblock-header-word_cloud', 'Word Cloud component displayed' ) if publish: self.q(css='.action-publish.action-primary').click() # Clicking on the publish button causes an ajax call. # We should be waiting for this ajax call to be completed # before exiting the function. self.wait_for_ajax()
def click_confirmation_prompt_primary_button(self): """ Clicks the main action presented by the prompt (such as 'Delete') """ disable_animations(self) self.q(css='.prompt button.action-primary').first.click() self.wait_for_element_invisibility('.prompt', 'wait for pop up to disappear') self.wait_for_ajax()
def register_white_label_user(self, registration_fields, submit=True): """ Registers a whitelabel users for whitelabel tests. Arguments: registration_fields(dict): A dictionary of all fields to be filled. submit(bool): If True then registration form will be submitted. """ disable_animations(self) self.wait_for_element_visibility('.form-toggle[data-type="login"]', 'Registration form is visible.') elements_and_values = { '#register-email': registration_fields['email'], '#register-name': registration_fields['name'], '#register-username': registration_fields['username'], '#register-password': registration_fields['password'], '#register-first_name': registration_fields['first_name'], '#register-last_name': registration_fields['last_name'], '#register-state': registration_fields['state'] } drop_down_names_and_values = { "country": registration_fields['country'], } select_drop_down_values(self, drop_down_names_and_values) fill_input_fields(self, elements_and_values) # Some tests still don't display the new registration page when running # on Jenkins. Once registration page is updated, remove this condition. if self.q(css='#register-honor_code').visible: click_checkbox(self, '#register-honor_code') click_checkbox(self, '#register-terms_of_service') if ORG == 'MITxPRO': fill_input_fields( self, { '#register-company': registration_fields['company'], '#register-title': registration_fields['title'] }) if ORG != 'HarvardMedGlobalAcademy': select_drop_down_values( self, { "year_of_birth": registration_fields['year_of_birth'], "gender": registration_fields['gender'], "level_of_education": registration_fields['level_of_education'] }) else: select_drop_down_values( self, { "profession": registration_fields['profession'], "specialty": registration_fields['specialty'] }) if submit: self.q(css='.register-button').click()
def click_delete(self): """ Click the button to delete this user. """ disable_animations(self) self.q(css=self._bounded_selector('.remove-user')).click() # We can't use confirm_prompt because its wait_for_ajax is flaky when the page is expected to reload. self.wait_for_element_visibility('.prompt', 'Prompt is visible') self.wait_for_element_visibility('.prompt .action-primary', 'Confirmation button is visible') self.q(css='.prompt .action-primary').click() self.wait_for_element_absence('.page-prompt .is-shown', 'Confirmation prompt is hidden') wait_for_ajax_or_reload(self.browser)
def click_view_live_button(self): """ Clicks view live button """ disable_animations(self) course_info = get_course_info() course_key = get_course_key({ 'course_org': course_info['org'], 'course_num': course_info['number'], 'course_run': course_info['run'] }) self.browser.execute_script( "document.querySelectorAll('[data-course-key = \"" "{}\"] .view-button')[0].click();".format(str(course_key))) self.browser.switch_to_window(self.browser.window_handles[-1])
def wait_until_ready(self): """ When the page first loads, there is a loading indicator and most functionality is not yet available. This waits for that loading to finish. This method is different from wait_until_no_loading_indicator because this expects the loading indicator to still exist on the page; it is just hidden. It also disables animations for improved test reliability. """ self.wait_for_element_invisibility( '.ui-loading', 'Wait for the page to complete its initial loading' ) disable_animations(self)
def wait_until_no_loading_indicator(self): """ When the page first loads, there is a loading indicator and most functionality is not yet available. This waits for that loading to finish and be removed from the DOM. This method is different from wait_until_ready because the loading element is removed from the DOM, rather than hidden. It also disables animations for improved test reliability. """ self.wait_for( lambda: not self.q(css='.ui-loading').present, "Wait for page to complete its initial loading" ) disable_animations(self)
def __init__(self, browser, element, parent_id): super(EdxNoteHighlight, self).__init__(browser, parent_id) self.element = element self.item_id = parent_id disable_animations(self)