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]#
get_browser_url()[source]#
get_screenshot_tolerance() float[source]#
get_uninteractable_element()[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_browser_test1()[source]#

Logs in as Test user 1.

login_browser_test2()[source]#

Logs in as Test user 2.

login_browser_test3()[source]#

Logs in as Test user 3.

login_dropdown_path = '//tim-login-menu/tim-user-menu/div/button'#
print_console()[source]#
refresh()[source]#

Refreshes the current browser page.

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_im(im, filename_or_file)[source]#
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'#
scroll_into_view(element: selenium.webdriver.remote.webelement.WebElement)[source]#
select_text(selector: str, start_offset: int, end_offset: int)[source]#
property sent_emails#
setUp()[source]#

Hook method for setting up the test fixture before exercising it.

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.

tearDown()[source]#

Hook method for deconstructing the test fixture after testing it.

temp_config(settings: dict[str, Any])[source]#
touch(e: selenium.webdriver.remote.webelement.WebElement)[source]#
use_left_menu()[source]#
wait_and_click(selector: str)[source]#
wait_for_editor_load()[source]#
wait_until_hidden(selector)[source]#
wait_until_present(selector)[source]#
wait_until_present_and_vis(selector)[source]#
wait_until_text_present(selector: str, text: str)[source]#
wait_until_val_present(selector: str, text: str)[source]#
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.browsertest.find_by_ngclick(element: selenium.webdriver.remote.webelement.WebElement, value: str, tagname='*') selenium.webdriver.remote.webelement.WebElement[source]#
timApp.tests.browser.browsertest.find_element_by_text(root: selenium.webdriver.remote.webelement.WebElement, text: str, element: str = '*') 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]#
test_referenced_area_plugin()[source]#

timApp.tests.browser.test_areas module#

class timApp.tests.browser.test_areas.AreasTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

check_menu(p, expected)[source]#
check_par_texts(pars: list[selenium.webdriver.remote.webelement.WebElement], expected: list[str])[source]#
close_menu(menu)[source]#
disable_ace()[source]#
edit_selection_and_save(menu: selenium.webdriver.remote.webelement.WebElement)[source]#
find_par_elems()[source]#
open_menu(p) selenium.webdriver.remote.webelement.WebElement[source]#
save_editor()[source]#
select_pars(start: str, end: str, toggle_edit: bool = False)[source]#
test_area_delete_par()[source]#
test_areas()[source]#
test_cut_two_areas()[source]#
test_edit_multiple_in_area()[source]#
test_edit_selection_collapsible()[source]#

timApp.tests.browser.test_csplugin module#

class timApp.tests.browser.test_csplugin.CsPluginTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

make_text_and_answer(d)[source]#
test_csplugin_answernr1()[source]#
test_csplugin_require_type()[source]#
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

test_csplugin_translation()[source]#
class timApp.tests.browser.test_csplugin.StackRandomTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_csplugin_answernr_stack1()[source]#

timApp.tests.browser.test_forms module#

class timApp.tests.browser.test_forms.FormTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_plugin_user_modifiers()[source]#

Save and show answers in browser according to global field and useCurrentUser logic

timApp.tests.browser.test_imagex module#

class timApp.tests.browser.test_imagex.ImagexTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_imagex_freehand_legacy()[source]#

Test imagex drawing and legacy freehand loading

timApp.tests.browser.test_jsrunner module#

class timApp.tests.browser.test_jsrunner.JsRunnerTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_area_visibility_toggle()[source]#

timApp.tests.browser.test_login module#

class timApp.tests.browser.test_login.LoginTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_login()[source]#

timApp.tests.browser.test_pareditor module#

class timApp.tests.browser.test_pareditor.ParEditorTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

get_editor_element() selenium.webdriver.remote.webelement.WebElement[source]#
open_editor_from_bottom()[source]#
test_add_bottom_focus_switch()[source]#

Ensures:

  • editor is opened from the “Add paragraph” button at the bottom

  • editor gets focus automatically on open

  • preview works

  • switching between plain text area and Ace works

test_autocomplete()[source]#
wait_for_preview_to_finish()[source]#
timApp.tests.browser.test_pareditor.get_cancel_button(pareditor) selenium.webdriver.remote.webelement.WebElement[source]#
timApp.tests.browser.test_pareditor.get_change_editor_button(pareditor) selenium.webdriver.remote.webelement.WebElement[source]#

timApp.tests.browser.test_postprogram_fields module#

class timApp.tests.browser.test_postprogram_fields.PostProgramFieldsTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_postprogram_fields()[source]#

timApp.tests.browser.test_questions module#

class timApp.tests.browser.test_questions.QuestionTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

do_question_test(answer_choices: list[int] | list[str], choices: list[tuple[str, str]], expected_answer: str, expected_points: float | None, expected_yaml: dict, headers: list[str], points: list[str], questiontype: str, type_choice: str, answer_type_choice=None, adjust_matrix=None)[source]#
test_questions()[source]#

Create document questions and answer them.

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]#
test_sisu_assessments_block()[source]#

Test that SCIM API can be blocked and relevant error message is displayed to the user

timApp.tests.browser.test_teacher module#

class timApp.tests.browser.test_teacher.TeacherTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_first_answer_loading()[source]#

First loaded answers in teacher view matches the first user that browser selects from a group

timApp.tests.browser.test_textfield_numericfield_multisave module#

class timApp.tests.browser.test_textfield_numericfield_multisave.TextfieldPluginTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

get_screenshot_tolerance()[source]#
test_textfield_numericfield_multisave()[source]#

timApp.tests.browser.test_timtable module#

class timApp.tests.browser.test_timtable.TimTableTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

find_and_save_timtable(name: str)[source]#
test_all_cell_styles()[source]#

Test case 1.5. All styles for cell-element.

test_all_column_styles()[source]#

Test case 1.3. All styles for column-element.

test_all_row_styles()[source]#

Test case 1.4. All styles for row-elements.

test_all_styles()[source]#

Test case 1.7. All styles..

test_all_table_styles()[source]#

Test case 1.6. All styles for table-element. :return:

test_colspan()[source]#

Test case 1.9. Colspan

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.

test_column_span()[source]#

Test case 1.14. Column span.

test_extra_properties()[source]#

Test case 1.8. Extra properties. Right way to function: Added extra properties senatus: “populusque romanus” Julius: Caesar Lucius: Vorenus Marcus: Aurelius have no effect. Screenshot should look just like timTableAllStyles.

test_many_things()[source]#

Test case 1.15. Many things.

test_rowspan()[source]#

Test case 1.10 Rowspan

test_rowspan_colspan()[source]#

Test case 1.13. Rowspan and colspan together.

test_rowspan_over_rows()[source]#

Test case 1.11 Rowspan over amount of rows.

test_simple()[source]#

Test case 1.2. Simple table.

test_svg_math()[source]#
test_tabledatablock()[source]#

Test case 1.16. Data block.

timApp.tests.browser.test_url_jsrunner module#

class timApp.tests.browser.test_url_jsrunner.TestUrlJsrunner(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_url_jsrunner()[source]#

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]#
test_numeric_urlmacro_default()[source]#
test_urlmacros()[source]#

timApp.tests.browser.test_usercontact module#

class timApp.tests.browser.test_usercontact.UserContactTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

get_screenshot_tolerance()[source]#
test_email_add()[source]#

timApp.tests.browser.test_velps module#

class timApp.tests.browser.test_velps.VelpTest(*args, **kwargs)[source]#

Bases: timApp.tests.browser.browsertest.BrowserTest

test_velp_user_filtering()[source]#
test_velps()[source]#

Ensures:

  • Velp selection component is visible in /velp route

  • New velp can be created

  • The created velp appears in the list of velps

Module contents#