def login(browser: Browser, email: str, password: str) -> None: """Log in through `/account/login` as the given user.""" browser.visit('/account/login') browser.fill_in('login', email) browser.fill_in('password', password) browser.click_button('Sign In') browser.wait_for_element('a', text='MY WORKFLOWS', wait=True)
def login(browser: Browser, email: str, password: str) -> None: """Log in through `/account/login` as the given user.""" browser.visit("/account/login") browser.fill_in("login", email) browser.fill_in("password", password) browser.click_button("Sign In") browser.wait_for_element("a", text="MY WORKFLOWS", wait=True)
def login(browser: Browser, email: str, password: str) -> None: """Log in through `/account/login` as the given user.""" # Selectors designed to work in any locale_id browser.visit("/account/login") browser.fill_in("login", email) browser.fill_in("password", password) browser.click_whatever('.account_form.login button[type="submit"]') browser.wait_for_element(".create-workflow")
def logout(browser: Browser) -> None: """Log out through `/account/logout` as the given user. The logout page must be in `locale_id` """ browser.visit("/account/logout") browser.click_whatever('.account_form button[type="submit"]') browser.wait_for_element(".account_form.login")
def login(browser: Browser, email: str, password: str) -> None: """Log in through `/account/login` as the given user. The login page must be in `locale_id`, while the workflows page must be in `after_login_locale_id` """ browser.visit("/account/login") browser.fill_in("login", email) browser.fill_in("password", password) browser.click_whatever('.account_form.login button[type="submit"]') browser.wait_for_element(".create-workflow")
def import_workbench_module(browser: Browser, slug: str) -> None: """Import a module by clicking through the browser. Assumes there's a context menu with an "Import Module" modal. """ browser.click_button('menu', wait=True) # wait for page to load browser.click_button('Import Module') browser.fill_in('url', f'http://git-server/{slug}.git', wait=True) browser.click_button('Import') browser.wait_for_element('.import-github-success', wait=True) browser.click_button('OK')
def logout(browser: Browser) -> None: """Log out through `/account/logout/` as the given user. This page exists because the framework generates it. We don't ever show it to users. """ # Selectors designed to work in any locale_id browser.visit("/account/logout/") browser.click_whatever( 'form[action="/account/logout/"] button[type="submit"]') browser.wait_for_element(".account_form.login")
def import_workbench_module(browser: Browser, slug: str) -> None: """ Import a module by clicking through the browser. Assumes there's a context menu with an "Import Module" modal. """ with browser.scope(".navbar", wait=True): # wait for page to load browser.click_button("menu") browser.click_button("Import Module") with browser.scope(".modal-dialog"): browser.fill_in("url", f"http://git-server/{slug}.git", wait=True) browser.click_button("Import") browser.wait_for_element(".import-github-success", text="Imported", wait=True) browser.click_button("×")
def import_workbench_module(browser: Browser, module_id: str) -> None: """ Import a module by clicking through the browser. Assumes there's a context menu with an "Import Module" modal. Side-effect: this will launch a singleton HTTP-server thread at http://module-zipfile-server:PORT, where PORT is an unused TCP port. """ server = _get_singleton_http_server() port = server.server_port path = ZIPFILE_PATHS[module_id] with browser.scope(".navbar", wait=True): # wait for page to load browser.click_button("menu") browser.click_button("Import Module") with browser.scope(".modal-dialog"): browser.fill_in("url", f"http://module-zipfile-server:{port}{path}", wait=True) browser.click_button("Import") browser.wait_for_element(".import-github-success", text="Imported", wait=True) browser.click_button("×")
def switch_locale_django(browser: Browser, to_locale_name: str): browser.click_whatever("a#locale-switcher-dropdown") browser.click_button(to_locale_name, wait=True) # check that the language has indeed changed browser.wait_for_element("a#locale-switcher-dropdown", text=to_locale_name)