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' ) add_button = self.q(css=self._bounded_selector(self.ADD_BUTTON_SELECTOR)).first.results 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')) 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') EmptyPromise( lambda: subsection_expanded() != currently_expanded, "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 click_create_certificate_button(self): """ Create a new certificate. """ disable_animations(self.page) self.find_css('.action-primary').first.click() self.page.wait_for_ajax()
def setUp(self): super(CertificateInvalidationTest, self).setUp() # set same course number as we have in fixture json self.course_info['number'] = "335535897951379478207964576572017930000" # we have created a user with this id in fixture, and created a generated certificate for it. self.student_id = "99" self.student_name = "testcert" self.student_email = "*****@*****.**" # Enroll above test user in the course AutoAuthPage( self.browser, username=self.student_name, email=self.student_email, course_id=self.course_id, ).visit() self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config) self.cert_fixture.install() self.user_name, self.user_id = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
def setUp(self): super(CertificateInvalidationTest, self).setUp() # set same course number as we have in fixture json self.course_info['number'] = "335535897951379478207964576572017930000" # we have created a user with this id in fixture, and created a generated certificate for it. self.student_id = "99" self.student_name = "testcert" self.student_email = "*****@*****.**" # Enroll above test user in the course AutoAuthPage( self.browser, username=self.student_name, email=self.student_email, course_id=self.course_id, ).visit() self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config) self.cert_fixture.install() self.user_name, self.user_id, __, __ = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
def click_css(page, css, source_index=0, require_notification=True): """ Click the button/link with the given css and index on the specified page (subclass of PageObject). Will only consider elements that are displayed and have a height and width greater than zero. If require_notification is False (default value is True), the method will return immediately. Otherwise, it will wait for the "mini-notification" to appear and disappear. """ def _is_visible(element): """Is the given element visible?""" # Only make the call to size once (instead of once for the height and once for the width) # because otherwise you will trigger a extra query on a remote element. return element.is_displayed() and all(size > 0 for size in element.size.itervalues()) # Disable all animations for faster testing with more reliable synchronization disable_animations(page) # Click on the element in the browser page.q(css=css).filter(_is_visible).nth(source_index).click() if require_notification: sync_on_notification(page) # Some buttons trigger ajax posts # (e.g. .add-missing-groups-button as configured in split_test_author_view.js) # so after you click anything wait for the ajax call to finish page.wait_for_ajax()
def click_css(page, css, source_index=0): """ Click the button/link with the given css and index on the specified page (subclass of PageObject). Will only consider elements that are displayed and have a height and width greater than zero. If require_notification is False (default value is True), the method will return immediately. Otherwise, it will wait for the "mini-notification" to appear and disappear. """ def _is_visible(element): """Is the given element visible?""" # Only make the call to size once (instead of once for the height and once for the width) # because otherwise you will trigger a extra query on a remote element. return element.is_displayed() and all( size > 0 for size in six.itervalues(element.size)) # Disable all animations for faster testing with more reliable synchronization disable_animations(page) # Click on the element in the browser page.q(css=css).filter(_is_visible).nth(source_index).click() # Some buttons trigger ajax posts # (e.g. .add-missing-groups-button as configured in split_test_author_view.js) # so after you click anything wait for the ajax call to finish page.wait_for_ajax()
def setUp(self): super(CertificatesTest, self).setUp() self.course_fixture = CourseFixture(**self.course_info).install() self.user_name, self.user_id = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
def setUp(self): super(CertificatesTest, self).setUp() self.course_fixture = CourseFixture(**self.course_info).install() self.user_name, self.user_id = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates( ) disable_animations(self.certificates_section)
def click_confirmation_prompt_primary_button(self): """ Clicks the main action presented by the prompt (such as 'Delete') """ disable_animations(self) self.wait_for_confirmation_prompt() 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 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 setUp(self, is_staff=True): # pylint: disable=arguments-differ """ Install a course with no content using a fixture. """ super(TextbooksTest, self).setUp(is_staff) self.textbook_upload_page = TextbookUploadPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run']) self.textbook_upload_page.visit() disable_animations(self) self.textbook_view_page = TextbookViewPage(self.browser, self.course_id)
def setUp(self, is_staff=True): """ Install a course with no content using a fixture. """ super(TextbooksTest, self).setUp(is_staff) self.textbook_upload_page = TextbookUploadPage( self.browser, self.course_info['org'], self.course_info['number'], self.course_info['run'] ) self.textbook_upload_page.visit() disable_animations(self) self.textbook_view_page = TextbookViewPage(self.browser, self.course_id)
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 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 setUp(self): super(CertificatesTest, self).setUp() self.test_certificate_config = { 'id': 1, 'name': 'Certificate name', 'description': 'Certificate description', 'course_title': 'Course title override', 'signatories': [], 'version': 1, 'is_active': True } CourseFixture(**self.course_info).install() self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config) self.cert_fixture.install() self.user_name, self.user_id = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
def test_annotation_component(self): """ Test annotation components links to annotation problems. """ annotation_component_page = self._goto_annotation_component_page() # This will avoid scrolling related problems on different browsers and instead directly jump on the problem disable_animations(annotation_component_page) for i in xrange(self.annotation_count): annotation_component_page.click_reply_annotation(i) self.assertTrue(annotation_component_page.check_scroll_to_problem()) annotation_component_page.answer_problem() self.assertTrue(annotation_component_page.check_feedback()) annotation_component_page.click_return_to_annotation() self.assertTrue(annotation_component_page.check_scroll_to_annotation())
def setUp(self): super(CertificatesTest, self).setUp() self.test_certificate_config = { "id": 1, "name": "Certificate name", "description": "Certificate description", "course_title": "Course title override", "signatories": [], "version": 1, "is_active": True, } CourseFixture(**self.course_info).install() self.cert_fixture = CertificateConfigFixture(self.course_id, self.test_certificate_config) self.cert_fixture.install() self.user_name, self.user_id = self.log_in_as_instructor() self.instructor_dashboard_page = self.visit_instructor_dashboard() self.certificates_section = self.instructor_dashboard_page.select_certificates() disable_animations(self.certificates_section)
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)