Welcome to LiveObs Selenium’s documentation!¶
Installation¶
To get started using the LiveObs Selenium library you first need to include it
in your project. You can do this adding the following to your
requirements.txt
:
git+git://github.com/BJSS/BJSS_liveobs_selenium.git@OPTIONAL_VERSION_NUMBER
Usage¶
Once you’ve got the library installed you can then import the page object models to interact with the LiveObs GUI.
Example:
from liveobs_ui.page_object_models.login_page import LoginPage
def login_into_liveobs(username, password):
"""
Log into the LiveObs Mobile Frontend
:param username: Username of user to log in with
:param password: Password of the user to log in with
""""
login_page = LoginPage(self.client) # self.client must be a webdriver
login_page.login(username, password)
You shouldn’t need to import the element selectors as these are intended for use within the page object models themselves. If you do need to use the element selectors then it’s suggested that you create a pull request with the functionality to add this back into the liveobs_selenium library.
Page Object Models¶
Page Object Models provide methods to interact with the pages they represent for instance using the Data Entry Page Object Model provides methods to fill out the observation form.
All Mobile Page Object Models are subclasses of BaseMobilePage
which
provides methods for going to the various mobile pages as well as common
interaction patterns such as clicking a button and waiting for a particular
element to become visible/invisible to verify the intended action has worked.
Login Page¶
The login page is the first page that mobile users see when they use LiveObs, they are prompted to enter their username and password (either supplied to them by a more privileged user or via LDAP).
For test and development purposes there may be multiple databases running on the one LiveObs instances, if this is the case then there will be a dropdown that allows for the selection of the database to log into.
Class Methods:¶
-
class
liveobs_ui.page_object_models.common.login_page.
LoginPage
(driver)[source]¶ Class that handles interaction with the Login Page
-
get_login_error_message
()[source]¶ Get error message shown after an unsuccessful login
Returns: Error message if present Return type: str or None
-
is_login_page
()[source]¶ Verify that we are indeed on the login page
Returns: if current page is the login page
-
login
(username, password, database=’nhclinical’, desktop=False)[source]¶ Fill out the login form and press the submit button
Parameters: - username – Username to login with
- password – Password for the username supplied
- database – Name of the database to log into if the database selection element is visible
- desktop – If the login is via desktop (as different field name)
-
Mobile Pages¶
There are a few common patterns for the mobile. These involve navigating around the app and verifying the page the user is on.
Data Entry Page¶
The Data Entry Page allows the user to enter data for the observation or escalation task they are doing. It has a floating header that allows the user to access information on the patient while filling out the form.
The page will have some inputs if needed to complete the form but this is not always the case however there will always be at least one button that will allow the user to complete or cancel the task they are doing.
Class Methods:¶
-
class
liveobs_ui.page_object_models.mobile.data_entry_page.
DataEntryPage
(driver)[source]¶ Class that handles interacting with the data entry form
-
close_patient_info
()[source]¶ Close the patient information popup, opened by pressing the button in the floating header
-
confirm_submit_scored_ob
()[source]¶ Confirm the ‘Submit Score of X for Y, Z’ modal that pops up after first pressing the submit button for scored observations.
-
get_clinical_risk_in_popup
(cli_risk_expected)[source]¶ Locates and returns the risk from an observation in the confirmation popup :param cli_risk_expected: value expected to be returned :return: string in specified element
-
get_data_model_from_form
()[source]¶ Get the dataa model for the form so we can use this to determine what to do
-
static
locate_attribute_path
(field_input)[source]¶ Identify the class of the input field and return the specific locator for their attributes
Parameters: field_input – the general locator for the field Returns: locator for the attribute in the DOM
-
submit_cancellation_reason
(cancel_reason)[source]¶ Select the specified cancellation reason and submit the modal to cancel the task
Parameters: cancel_reason – Name of reason to select
-
submit_form
()[source]¶ Try to press the submit button on the form. Otherwise scroll down and try again. (Scroll implemented to deal with EOBS-1864)
-
take_escalation_task
()[source]¶ Take the escalation task presented to the user once an observation that has escalation tasks is submitted
-
verify_obs_field_displayed
(obs_field)[source]¶ Locates a specific field in an observation form and verifies its visibility
Parameters: obs_field – the observation field to look for
-
List Page¶
The list page is a base class for the task and patient list as these use the same template to render their respective lists.
This class handles selecting items in the list as well as verifying the text in the list items.
Class Methods:¶
-
class
liveobs_ui.page_object_models.mobile.list_page.
ListPage
(driver)[source]¶ Class that handles generic list page functionality
-
get_list_item
(text_to_find)[source]¶ Get a specific item from the list
Parameters: text_to_find (str) – Text that should be in the list item to be found Returns: The list item if found or None
-
get_list_items
()[source]¶ Get a list of the items in the task / patient list
Returns: A list of a
tags from the listReturn type: list
-
static
get_patient_from_item
(list_item)[source]¶ Get the patient’s name from list item
Parameters: list_item – WebElement for List Item Returns: name of patient the list item is about
-
static
get_task_info_from_item
(list_item)[source]¶ Get the .taskInfo element from the list item
Parameters: list_item – WebElement for List Item Returns: text inside .taskInfo element of List Item
-
Modal Page¶
As a modal is a change in context there is a separate page object model to cover this. Having a page object model for this also helps with code reuse.
Class Methods:¶
-
class
liveobs_ui.page_object_models.mobile.modal_page.
ModalPage
(driver)[source]¶ Class that handles interacting with Modals
-
click_modal_option
(modal, option_title)[source]¶ Locate the option in the modal options and click it
Parameters: - modal – Modal to find option in
- option_title – Title of the button to click
-
get_cover_for_modal
(modal)[source]¶ Get the cover that is associated with the modal
Parameters: modal – Modal to find cover for Returns: cover object
-
static
get_modal_content
(modal)[source]¶ Get the text content of the supplied modal
Parameters: modal – Modal to get content of Returns: Text content of modal
-
static
get_modal_options
(modal)[source]¶ Get the option buttons for the supplied modal
Parameters: modal – Modal to find option buttons for Returns: List of button elements
-
Patient Page¶
The Patient Page shows the user the observation information about the patient they have selected. From this screen they can select an observation to carry out ad-hoc, change the observation data they are looking at and change the rapid tranquilisation status of the patient.
Class Methods:¶
-
class
liveobs_ui.page_object_models.mobile.patient_page.
PatientPage
(driver)[source]¶ Class that handles interacting with patient graphs and ad-hoc observation menu
Close the ad-hoc observation menu
-
get_observation_in_list
(observation_name)[source]¶ Find the specified observation and open the observation form
Parameters: observation_name – Name of the observation to open Returns: Boolean. Returns if the page is the intended observation
Select the specified observation from the ad-hoc observation menu
Parameters: observation_name (str) – Name of the observation to select Returns: WebElement for that observation
Get a list of the ad-hoc observations in the ‘Take Observation’ menu :return: list of WebElements
Press the ‘Take Observation’ button to open the ad-hoc observation list
-
class
liveobs_ui.page_object_models.mobile.mobile_common.
BaseMobilePage
(driver)[source]¶ Base class to initialise the base page that will be called from all pages
Find a button in the page by name
Returns: the button element on the page
-
is_patient_list
()[source]¶ Are we on the patient list?
Returns: If current URL is the patient list URL Return type: bool
Desktop Pages¶
As the desktop for LiveObs uses Odoo’s webclient there are a number of common page objects that can be interactive. These are the top and left navigations, the search box and the view switch buttons.
Account Administration Page¶
The Account Administration page shows the users in the system. This allows users with the correct permissions to change these user’s roles in the system.
Acuity Board Page¶
The Acuity Board Page shows a kanban view where patients are sorted into the columns based on their ward or their clinical risk. Users can also filter the items in the view based on clinical risk or by NEWS trend.
Allocation Wizard Interaction¶
The allocation wizard allows for the assignment of a nurse and multiple HCAs to a bed location.
-
class
liveobs_ui.page_object_models.desktop.allocation_wizard.
AllocationWizard
(driver)[source]¶ Interacting with the Allocation Wizard. The Allocation Wizard is presented to the user at the 4th stage of the Nursing Shift Change Wizard and the 2nd stage of the Staff Re-allocation Wizard.
-
set_allocation
(nurse, hca_list)[source]¶ Set the allocation for the wizard
Parameters: - nurse – Nurse to set for the allocation
- hca_list – List of HCAs to set for the allocation
-
Common Form View Interactions¶
There are common actions that apply to the form view. These involve getting action buttons and tabs.
-
class
liveobs_ui.page_object_models.desktop.form_view_common.
BaseFormViewPage
(driver)[source]¶ Interaction with form view
Get a button that sits in the form’s actionbar that has the specified name
Parameters: button_name – Name of button to get Returns: Button element
Get the buttons that sit in the form’s actionbar
Returns: List of button elements
Common Kanban View Interaction¶
There are a number of common interaction patterns we need to do for kanban views. These involve getting a list of kanban cards and opening them.
-
class
liveobs_ui.page_object_models.desktop.kanban_view_common.
BaseKanbanViewPage
(driver)[source]¶ Interaction with Kanban views
-
get_kanban_card_by_name
(search_string)[source]¶ Get a kanban card that contains the specified search string
Parameters: search_string – String to find in kanban card content Returns: Kanban card element
-
get_kanban_cards
()[source]¶ Get all the kanban cards in the current view
Returns: List of kanban card elements
-
open_kanban_card
(card)[source]¶ Open the supplied kanban card
Parameters: card – Element for kanban card to open
-
Common List View Interaction¶
There are a number of common interaction patterns we need to do for list views. These involve getting the list of items in the list view and getting a specific list item.
-
class
liveobs_ui.page_object_models.desktop.list_view_common.
BaseListViewPage
(driver)[source]¶ Common functionality for list view pages
-
get_list_item_by_name
(search_string)[source]¶ Get a specific list item for the supplied string
Parameters: search_string – String to find in row Returns: element for list item with string it in
-
open_list_item
(list_item)[source]¶ Open the supplied list item
Parameters: list_item – List Item to open
-
Common Modal View Interactions¶
There are a number of common interaction patterns with modals such as closing them or clicking the buttons at the bottom of the modal.
-
class
liveobs_ui.page_object_models.desktop.modal_view_common.
BaseModalPage
(driver)[source]¶ Common interaction patterns with modal dialogs
Click a button in modal’s footer with a specified name
Parameters: - modal – Modal to click button in
- name – Name of button to click
-
get_currently_open_modal
()[source]¶ Get the currently open modal on the screen
Returns: Modal element
Get a button in the modal’s footer with a specified name
Parameters: - modal – Modal to find button in
- name – Name of button
Returns: button element
Get the buttons in the supplied modal’s footer
Parameters: modal – Modal to get buttons for Returns: list of button elements
Nursing Shift Change Wizard Interaction¶
The Nursing Shift Change Wizard is a modal wizard that guides the user through four stages, ward selection, deallocation, roll call and allocation.
-
class
liveobs_ui.page_object_models.desktop.nursing_shift_change_wizard.
NursingShiftChangeWizard
(driver)[source]¶ Interacting with the Nursing Shift Change Wizard and it’s different stages
-
allocate
(allocation_map)[source]¶ Allocate users to beds
Parameters: allocation_map – dictionary containing mapping of users to beds
-
collect_current_allocation
()[source]¶ Get the current user(s) -> bed allocation from the de-allocation screen
Returns: list of dictionaries representing beds and the different nurse and HCA users allocated to that bed
Get the button to take the user to next stage of the wizard
Returns: webelement for button
-
roll_call
(user_list)[source]¶ Add all users that were originally on ward back into ward
Parameters: user_list – list of names to enter into input so these users can then be allocated to the beds in the ward
-
select_ward
(ward_name)[source]¶ Get currently logged in user’s ward and select it in dropdown
Parameters: ward_name – Name of ward to select for Nursing Shift change
-
Overdue Tasks Page¶
The Overdue Tasks lists tasks that have a deadline on or before the current time. This page allows users to see what tasks need to be done urgently on the ward(s) they are responsible for.
Patient Record Page¶
The Patient Record page shows the demographics for the patient and allows the user to access the observation data for the patient too. There is also functionality to move the patient around the ward, print a PDF of the patients data and stop the observations for the patient.
Patients By Ward Page¶
the Patients By Ward Page shows a list of patients grouped by ward. The user can then click on buttons to open the patient’s EWS Chart or EWS data and they can open the record for the patient.
-
class
liveobs_ui.page_object_models.desktop.patients_by_ward.
PatientsByWardPage
(driver)[source]¶ Interaction with Patients By Ward Page
-
open_patient_chart_popup
(patient_name)[source]¶ Find the row in the list for the supplied patient then open the chart popup
Parameters: patient_name – Name of patient who’s chart we want to open
-
Patients Without Bed¶
The Patients Without Bed page lists patients who are currently associated with the ward but not placed in a bed. The user will then select a patient and place them into a bed via this page.
-
class
liveobs_ui.page_object_models.desktop.patients_without_bed.
PatientsWithoutBedPage
(driver)[source]¶ Interaction with Patients Without Bed Page
Recently Discharged / Transferred Pages¶
The Recently Discharged and Recently Transferred pages show the user patients who have been discharged or transferred from the ward they are allocated to in the last 72 (by default) hours.
The number of hours that records are shown for is configurable by the System Administrator.
Wardboard Common Functionality¶
The Wardboard is a view on the patients in the ward the user is allocated to. This can be as a kanban, list or form view.
Common functionality for the page involves filtering and grouping the data in the views by clinical risk, score trend and location.
-
class
liveobs_ui.page_object_models.desktop.desktop_common.
BaseDesktopPage
(driver)[source]¶ Base class to initialise the base page that will be called from all pages
-
change_view_mode
(view_mode)[source]¶ Click the supplied view_mode button
Parameters: view_mode – View mode to select
Click on the supplied breadcrumb and verify that it is no longer on the page
Parameters: breadcrumb – Breadcrumb element to click
Get the breadcrumbs that allow to go back up a page in the navigation
Returns: list of breadcrumb elements
Returns the text attribute of an element on an item in the left menu section on the desktop app
Parameters: menu_item – WebElement from where to get the text element Returns: The text within the WebElement Return type: unicode
Returns a list of all the items in the left menu section on the desktop app
Returns: A list of all the WebElement items Return type: List of WebElements
-
go_to_next_record_in_list
()[source]¶ Click the next record button in the list of records. This is shown on the form view
-
go_to_page
(page_title)[source]¶ Go to the supplied page in the left hand menu based on the title of the page
Parameters: page_title – Title of the page to go to
-
go_to_previous_page
()[source]¶ Go back to the page used to get to the patient record in the breadcrumbs
-
go_to_previous_record_in_list
()[source]¶ Click the previous record button in the list of records. This is shown on the form view
-
perform_search
(search_query, search_type=None)[source]¶ Using the searchview conduct a search with the supplied search query
Parameters: - search_query – Query to input into the search box
- search_type – Type of search (uses Odoo Search autocomplete)
-
Common Methods:¶
-
class
liveobs_ui.page_object_models.common.base_liveobs_page.
BaseLiveObsPage
(driver)[source]¶ Base Page for all LiveObs Interaction
-
click_and_verify_change
(el_to_click, el_to_verify, hidden=False)[source]¶ Wrapper around clicking an element and then waiting for a change in the page and verifying said change by ensuring an element is visible
Parameters: - el_to_click – Element to click to induce change
- el_to_verify – Element to look for to verify change
- hidden – Should check for if element is now hidden or not
-
static
element_is_displayed
(element_object)[source]¶ Verify that an element is visible on the page
Parameters: element_object – the object or element to verify Returns: either True/False for the element being displayed
-
enter_input_value
(element, value, autocompleted=False, dropdown=False)[source]¶ Enter a value into an input field
Parameters: - element – webelement we want to add value to
- value – Value we want to add
- autocompleted – If should wait for autocomplete box to show before continuing
- dropdown – If should wait for the different type of dropdown to show before continuing
-
enter_many2one_tag_value
(element, value)[source]¶ Add value to many2one tag input then verify that the tag has been added
Parameters: - element – many2one tag input element
- value – value to add to the many2one input
-
fill_input_field
(element, value)[source]¶ Enter a value into an input field
Parameters: - element – webelement we want to add value to
- value – Value to enter into input
-
fill_out_form
(data)[source]¶ Using the provided list fill out the form
Expected Data Format:
{ 'name': 'respiration_rate', 'value': '18', 'type': 'textbox' }
Parameters: data – list of dictionaries that contain field names, value to enter and field type
-
fill_select_field
(element, value)[source]¶ Select an option in a select field
Parameters: - element – Select we want to sort out’s webelement
- value – Value to select in the select field
-
get_element_by_lookup
(element_name)[source]¶ Get an element by the lookup :param element_name: look up term to match :return: webelement
-
static
get_locator
(element)[source]¶ Get locator for element
Parameters: element – webelement we want to generate locator for Returns: Locator for supplied element
-
static
get_state_of_el
(element, attribute, state)[source]¶ Return if attribute on element is a particular state :param element: Webelement :param attribute: attribute to find :param state: expected value :return: bool
-
verify_page_loaded
(app_view)[source]¶ Waits for a specific element to be visible on the screen the ‘desktop’ or ‘mobile’ app to ensure the page has loaded before progressing
Parameters: app_view – Either ‘mobile’ or ‘desktop’
-
wait_for_element
(element_selector, hidden=False, wait_time=None)[source]¶ Wrapper around WebDriverWait to wait for specified element to become visible
Parameters: - element_selector (tuple) – Element Selector tuple
- hidden (bool) – Check if element is hidden or not
- wait_time (int) – Custom time to wait
-
Utility Functions¶
There are a number of utility functions that help with running selenium against the UI.
Converters¶
Converters for use with Selenium