def load_root_page(self): ret = pageobjects.RootPage(self).load( suite.TestBase.INTEGRATION_SERVER_BASE_URL) tries = 10 while tries and 'This webpage is not avail' in self.driver.page_source: tries -= 1 time.sleep(1) ret = pageobjects.RootPage(self).load( suite.TestBase.INTEGRATION_SERVER_BASE_URL) return ret
def test_embed_local_errors(self): # Broken into its own test because we need to make sure that you can # have embeds in a success state and embeds in a failed state. This # cannot happen if there are any global errors, since global errors put # all embeds in a failed state. self.load_sample_course() self.enable_module_handlers() pageobjects.RootPage(self).click_logout() local_error_page = pageobjects.EmbedModuleDemoPage(self).load( self.get_local_errors_url()) local_error_page.click_first_sign_in_control() self.switch_to_login_window().login(self.email) local_error_page = self.switch_to_demo_window() # The first embed renders successfully. embed_srcs = local_error_page.get_cb_embed_srcs() self.assert_embeds_loaded_in_iframes(local_error_page, [embed_srcs[0]]) # The second contains a global and a local error. global_error_message = ( 'Embed src ' '"http://localhost:8082/sample/modules/embed/v1/resource/example/' '2" does not match origin "http://localhost:8081"') local_error_message = ( 'Embed src ' '"http://localhost:8082/sample/modules/embed/v1/resource/example/ ' '2" does not match first cb-embed src found, which is from the ' 'deployment at "http://localhost:8081/sample/modules/embed/v1". ' 'All cb-embeds in a single page must be from the same Course ' 'Builder deployment.')
def test_embed_global_errors(self): self.load_sample_course() self.enable_module_handlers() pageobjects.RootPage(self).click_logout() global_error_page = pageobjects.EmbedModuleDemoPage(self).load( self.get_global_errors_url()) # Error caused by deployment not matching page origin -- a global error. first_embed_error_message = ( 'Embed src ' '"http://other:8081/sample/modules/embed/v1/resource/example/1" ' 'does not match origin "http://localhost:8081"') self.assert_cb_embed_contains_error(global_error_page, 0, first_embed_error_message) # Error caused by deployment not matching page origin -- a global error. second_embed_global_error = ( 'Embed src ' '"http://localhost:8082/sample/modules/embed/v1/resource/example/' '2" does not match origin "http://localhost:8081"') # Error caused by src not matching src of 0th embed -- a local error. second_embed_local_error = ( 'Embed src ' '"http://localhost:8082/sample/modules/embed/v1/resource/example/' '2" does not match first cb-embed src found, which is from the ' 'deployment at "http://other:8081/sample/modules/embed/v1". All ' 'cb-embeds in a single page must be from the same Course Builder ' 'deployment.') self.assert_cb_embed_contains_error(global_error_page, 1, second_embed_global_error) self.assert_cb_embed_contains_error(global_error_page, 1, second_embed_local_error)
def test_embed_render_lifecycle(self): self.load_sample_course() self.enable_module_handlers() pageobjects.RootPage(self).click_logout() demo_page = pageobjects.EmbedModuleDemoPage(self).load( self.get_demo_url()) self.assert_cb_embed_iframes_not_present(demo_page) cb_embed_srcs = demo_page.get_cb_embed_srcs() demo_page.click_first_sign_in_control() self.switch_to_login_window().login(self.email) demo_page = self.switch_to_demo_window() self.assert_cb_embed_iframes_present(demo_page) self.assert_embeds_loaded_in_iframes(demo_page, cb_embed_srcs)
def load_root_page(self): return pageobjects.RootPage(self).load( suite.TestBase.INTEGRATION_SERVER_BASE_URL)