timApp.tests.browser package
Contents
timApp.tests.browser package#
Submodules#
timApp.tests.browser.browsertest module#
- class timApp.tests.browser.browsertest.BrowserTest(*args, **kwargs)[source]#
Bases:
timApp.tests.timliveserver.TimLiveServer
,timApp.tests.server.timroutetest.TimRouteTest
- assert_same_screenshot(element: selenium.webdriver.remote.webelement.WebElement, filename: str | list[str], move_to_element: bool = False, attempts=1)[source]#
Asserts that the provided element looks the same as in the provided screenshot.
- Parameters
attempts – Number of comparison attempts.
element – The element to check.
filename – The filename of the expected screenshot.
move_to_element – Whether to move to the element before taking the screenshot.
- find_element(selector: Optional[str] = None, xpath: Optional[str] = None, parent: Optional[selenium.webdriver.remote.webelement.WebElement] = None) selenium.webdriver.remote.webelement.WebElement [source]#
- find_element_and_move_to(selector: str, times=1, parent: Optional[selenium.webdriver.remote.webelement.WebElement] = None) selenium.webdriver.remote.webelement.WebElement [source]#
- find_element_avoid_staleness(selector: Optional[str] = None, xpath: Optional[str] = None, tries: int = 20, click=False, parent=None, poll_rate=0.5) selenium.webdriver.remote.webelement.WebElement [source]#
- find_element_by_text(text: str, element: str = '*', staleness_attempts=1, parent: Optional[selenium.webdriver.remote.webelement.WebElement] = None) selenium.webdriver.remote.webelement.WebElement [source]#
- goto(url: str)[source]#
Navigates to a new URL using the browser.
- Parameters
url – The URL to which to navigate. This must be relative.
- goto_document(d: timApp.document.docinfo.DocInfo, view='view', query=None)[source]#
- login(email: Optional[str] = None, passw: Optional[str] = None, username: Optional[str] = None, add: bool = False, force: bool = True, **kwargs)[source]#
Logs a user in.
- Parameters
force – Unused parameter; must be defined so that it is not in kwargs.
username – The username of the user.
email – The email of the user.
passw – The password of the user.
add – Whether to add this user to the session group.
- Returns
Response as a JSON dict.
- login_browser_as(email: str, password: str, name: str) None [source]#
Logs in as a user with the given email and password and tests that the user is logged in.
- Parameters
email – User email
password – User password
name – User’s full name. Used to test that the user is logged in properly.
- login_browser_quick_test1()[source]#
Logs testuser 1 in quickly by directly adding the session cookie to the browser.
- login_browser_quick_test2()[source]#
Logs testuser 2 in quickly by directly adding the session cookie to the browser.
- login_dropdown_path = '//tim-login-menu/tim-user-menu/div/button'#
- save_element_screenshot(element: selenium.webdriver.remote.webelement.WebElement, filename_or_file: Optional[Union[str, _io.BytesIO]] = None, move_to_element: bool = False) wand.image.Image [source]#
Saves the screenshot of an element to a PNG file.
- Returns
The image object.
- Parameters
element – The element to save.
filename_or_file – Filename for the image without extension, a file object or None. If None, the image exists only in memory.
move_to_element – Whether to move to the element before taking the screenshot. Use this if there is a possibility that the element is not in viewport.
- save_screenshot(filename: str = 'screenshot')[source]#
Saves the current browser screen to a PNG file in screenshots directory.
- Parameters
filename – The file name of the PNG file.
- screenshot_dir = '/service/screenshots'#
- property sent_emails#
- should_not_exist(css_selector: str)[source]#
Asserts that the current document should not contain any elements that match the specified CSS selector.
- Parameters
css_selector – The CSS selector to test.
- timApp.tests.browser.browsertest.find_all_by_ngmodel(element: selenium.webdriver.remote.webelement.WebElement, model: str, tagname='*') list[selenium.webdriver.remote.webelement.WebElement] [source]#
- timApp.tests.browser.browsertest.find_button_by_text(root: selenium.webdriver.remote.webelement.WebElement, text: str)[source]#
- timApp.tests.browser.browsertest.find_by_attr_name(element: selenium.webdriver.remote.webelement.WebElement, model: str, tagname='*') selenium.webdriver.remote.webelement.WebElement [source]#
timApp.tests.browser.test_answerbrowser module#
- class timApp.tests.browser.test_answerbrowser.AnswerBrowserTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- check_reference_answerbrowser_ok(d: timApp.document.docentry.DocEntry)[source]#
timApp.tests.browser.test_areas module#
- class timApp.tests.browser.test_areas.AreasTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- check_par_texts(pars: list[selenium.webdriver.remote.webelement.WebElement], expected: list[str])[source]#
timApp.tests.browser.test_csplugin module#
- class timApp.tests.browser.test_csplugin.CsPluginTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- test_csplugin_saveindicators()[source]#
Check that savebutton is enabled/disabled by whatever is the current desired logic. For now: disableUnchanged false or missing: savebutton always enabled disableUnchanged true: savebutton disabled if saved and input doesn’t change Also check yellow margin is (un)hidden and savedText (dis)appears
timApp.tests.browser.test_forms module#
timApp.tests.browser.test_imagex module#
timApp.tests.browser.test_jsrunner module#
timApp.tests.browser.test_login module#
timApp.tests.browser.test_pareditor module#
- class timApp.tests.browser.test_pareditor.ParEditorTest(*args, **kwargs)[source]#
timApp.tests.browser.test_postprogram_fields module#
timApp.tests.browser.test_questions module#
- class timApp.tests.browser.test_questions.QuestionTest(*args, **kwargs)[source]#
- timApp.tests.browser.test_questions.adjust_matrix_size(dialog: selenium.webdriver.remote.webelement.WebElement, missing_choices: int, rowcol: str)[source]#
- timApp.tests.browser.test_questions.create_yaml(field_type: str, question_type: str, choices: list[tuple[str, str]], points_str: Optional[str] = None, headers=None, matrix_type=None)[source]#
- timApp.tests.browser.test_questions.get_matrix_fields(dialog: selenium.webdriver.remote.webelement.WebElement) tuple[list[selenium.webdriver.remote.webelement.WebElement], list[selenium.webdriver.remote.webelement.WebElement], list[selenium.webdriver.remote.webelement.WebElement], list[selenium.webdriver.remote.webelement.WebElement]] [source]#
timApp.tests.browser.test_sisu module#
- class timApp.tests.browser.test_sisu.SisuTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- do_test_scim_block(test_doc: timApp.document.docinfo.DocInfo)[source]#
timApp.tests.browser.test_teacher module#
timApp.tests.browser.test_textfield_numericfield_multisave module#
timApp.tests.browser.test_timtable module#
- class timApp.tests.browser.test_timtable.TimTableTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- test_colspan_over_columns()[source]#
Test case 1.12. Colspan over the amount of columns. Right way to function is like HTML normally would with these colspan values.
timApp.tests.browser.test_url_jsrunner module#
timApp.tests.browser.test_urlmacros module#
- class timApp.tests.browser.test_urlmacros.UrlMacroTest(*args, **kwargs)[source]#
Bases:
timApp.tests.browser.browsertest.BrowserTest
- check_console(d: timApp.document.docinfo.DocInfo, console_text: str, query: Optional[dict[str, str]] = None)[source]#