def test_translations(web_fixture, translation_example_fixture): """The user can choose between languages. The text for which translations exist change accordingly.""" browser = translation_example_fixture.browser browser.open('/') assert browser.is_element_present(XPath.heading(1).with_text("Addresses")) assert browser.is_element_present(XPath.label().with_text("Name")) #go to the the translated page browser.click(XPath.link().with_text('Afrikaans')) assert browser.is_element_present(XPath.heading(1).with_text("Adresse")) assert browser.is_element_present(XPath.label().with_text("Naam"))
def test_submit_form_with_invalid_csrf_token(web_fixture, csrf_fixture): """A Form cannot be submitted without the original CSRF token proving that it was rendered by us originally.""" fixture = csrf_fixture wsgi_app = web_fixture.new_wsgi_app(child_factory=fixture.MyForm.factory(), enable_js=True) web_fixture.reahl_server.set_app(wsgi_app) browser = web_fixture.driver_browser browser.open('/') fixture.set_csrf_token_in_rendered_form(browser, 'invalid csrf token value') assert not browser.is_element_present( XPath.heading(1).with_text("403 Forbidden")) browser.click(XPath.button_labelled('Submit')) assert browser.is_element_present( XPath.heading(1).with_text("403 Forbidden"))
def with_custom_error_page(self): self.root_ui = BreakingUIWithCustomErrorPage self.expected_error_text = 'Oops, something broke' self.error_element = XPath.heading(1)
def check(browser): assert browser.is_element_present( XPath.heading(1).with_text('My custom error page'))
def check(browser): assert browser.is_element_present( XPath.heading(1).with_text('An error occurred:').inside_of( XPath.div()))
def heading_is_displayed(self): return self.browser.is_element_present( XPath.heading(1).with_text('Addresses'))