_interactor

class appian_locust._interactor.DataTypeCache

Bases: object

cache(response_in_json: Dict[str, Any]) → None

From the given json response, finds and caches the data type :param response_in_json: response of the API request

clear() → None

Clears the data type cache

get() → str

Concatenates all cached data types and returns a string

Returns: concatenated cached data type string

class appian_locust._interactor._Interactor(session: locust.clients.HttpSession, host: str, portals_mode: bool = False)

Bases: object

_make_file_metadata(id: int) → dict

Produces a file metadata object to use for multifile upload fields

Parameters:

id (int) – Document id of the object

Returns:

Dictionary of the multifile upload data

Return type:

dict

check_login(resp: locust.clients.ResponseContextManager) → None

Given a response, checks to see if it’s possible that we are not logged in and then performs a login if we are not

Parameters:

resp – Response to check

Returns: None

click_button(post_url: str, component: Dict[str, Any], context: Dict[str, Any], uuid: str, label: str = None, headers: Dict[str, Any] = None, client_mode: str = None) → Dict[str, Any]

Calls the post operation to click certain SAIL components such as Buttons and Dynamic Links

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • component – the JSON code for the desired component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

Returns: the response of post operation as json

click_component(post_url: str, component: Dict[str, Any], context: Dict[str, Any], uuid: str, label: str = None, headers: Dict[str, Any] = None, client_mode: str = None) → Dict[str, Any]

Calls the post operation to click certain SAIL components such as Buttons and Dynamic Links

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • component – the JSON code for the desired component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

Returns: the response of post operation as json

click_generic_element(post_url: str, component: Dict[str, Any], context: Dict[str, Any], uuid: str, new_value: Dict[str, Any], label: str = None) → Dict[str, Any]

Calls the post operation to click on a generic element

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • component – the JSON code for the component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • new_value – value for the payload

  • label – the label to be displayed by locust for this action

Returns: the response of post operation as json

Calls the post operation to click certain SAIL components such as Buttons and Dynamic Links

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • component – the JSON code for the desired component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

Returns: the response of post operation as json

Use this function to interact specifically with record links, which represent links to new sail forms. :param get_url: the url (not including the host and domain) to navigate to :param component: the JSON code for the RecordLink :param context: the Sail context parsed from the json response :param label: the label to be displayed by locust for this action :param headers: header for the REST API call

Returns: the response of get RecordLink operation as json

click_record_search_button(post_url: str, component: Dict[str, Any], context: Dict[str, Any], uuid: str, label: str = None) → Dict[str, Any]

Calls the post operation to click a record search button

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • component – the JSON code for the desired SearchBoxWidget component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • label – the label to be displayed by locust for this action

Returns: the response of post operation as json

Use this function to interact with related action links, which start a process and return the start form. This can handle both relation actions and related action links that open in a dialog.

Parameters:
  • component – the JSON representing the Related Action Link

  • record_type_stub – record type stub for the record

  • opaque_record_id – opaque id for the record

  • opaque_related_action_id – opaque id for the related action

  • locust_request_label – label to be used within locust

  • open_in_a_dialog – Does this link open in a dialog

Returns: the start form for the related action

click_selected_tab(post_url: str, tab_group_component: Dict[str, Any], tab_label: str, context: Dict[str, Any], uuid: str) → Dict[str, Any]

Calls the post operation to send an update to a tabgroup to select a tab

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • tab_group_component – the JSON representing the desired TabButtonGroup SAIL component

  • tab_label – Label of the tab to select

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • label – the label of the tab to select. It is one of the tabs inside TabButtonGroup

Returns: the response of post operation as json

Use this function to interact with start process links, which start a process and return the start form. :param component: the JSON representing the Start Process Link :param process_model_opaque_id: opaque id for the process model of the Start Process Link :param cache_key: cachekey for the start process link :param site_name: name of site for link in starting process model. :param page_name: name of page for link in starting process model. :param is_mobile: indicates if it should hit the mobile endpoint. :param locust_request_label: label to be used within locust

Returns: the response of get Start Process Link operation as json

fill_pickerfield_text(post_url: str, picker_field: Dict[str, Any], text: str, context: Dict[str, Any], uuid: str, label: str = None) → Dict[str, Any]

Fill a Picker field with the given text and randomly select one of the suggested item :param post_url: the url (not including the host and domain) to post to :param picker_field: the picker field component returned from find_component_by_attribute_in_dict :param text: the text to fill into the picker field :param context: the SAIL context parsed from the json response :param uuid: the uuid parsed from the json response :param label: the label to be displayed by locust for this action

Returns: the response of post operation as json

fill_textfield(post_url: str, text_field: Dict[str, Any], text: str, context: Dict[str, Any], uuid: str, label: str = None) → Dict[str, Any]

Fill a TextField with the given text :param post_url: the url (not including the host and domain) to post to :param text_field: the text field component returned from find_component_by_attribute_in_dict :param text: the text to fill into the text field :param context: the Sail context parsed from the json response :param uuid: the uuid parsed from the json response :param label: the label to be displayed by locust for this action

Returns: the response of post operation as json

get_page(uri: str, headers: Optional[Dict[str, Any]] = None, label: str = None, check_login: bool = True) → requests.models.Response

Given a uri, executes GET request and returns response

Parameters:
  • uri – API URI to be called

  • headers – header for the REST API Call

  • label – the label to be displayed by locust

  • check_login – optional boolean to bypass checking if we are logged in

Returns: Json response of GET operation

get_primary_button_payload(page_content_in_json: Dict[str, Any]) → Dict[str, Any]

Finds the primary button from the page content response and creates the payload which can be used to simulate a click

Parameters:

page_content_in_json – full page content that has a primary button

Returns: payload of the primary button

get_webapi(uri: str, headers: Dict[str, Any] = None, label: str = None, queryparameters: Dict[str, Any] = {}) → requests.models.Response

Same as get_page. Additionally it accepts the query parameter to add query parameter while running “GET” operation :param uri: API URI to be called :param headers: header for the REST API Call :param label: the label to be displayed by locust :param queryparameters: Queries/Filters

Returns: Json response of GET operation

To set custom headers

>>> headers = self.appian.interactor.setup_request_headers()
... headers['Is-Admin'] = 'true'
... self.appian.interactor.get_webapi('/suite/webapi/headers', headers=headers)

To set custom query parameters

>>> params = {'age': 5, 'start-date': '10-05-2020'}
... self.appian.interactor.get_webapi('/suite/webapi/query', queryparameters=params)
interact_with_record_grid(post_url: str, grid_component: Dict[str, Any], context: Dict[str, Any], uuid: str, context_label: str = None) → Dict[str, Any]

Calls the post operation to send a record grid update

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • grid_component – the JSON dict representing the grid to update

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • context_label – the label to be displayed by locust for this action

Returns: the response of post operation as json

launch_query_editor(post_url: str, editor_component: Dict[str, Any], context: Dict[str, Any], uuid: str, expr: str, label: str = None) → Dict[str, Any]

Calls the post operation to click on the LaunchVQD button in the toolbar for the ExpressionEditorWidget. This will launch the query editor with the provided expression.

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • editor_component – the JSON code for the expression editor component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • expr – expression in the expression editor

  • label – the label to be displayed by locust for this action

Returns: the response of post operation as json

login(auth: list = None, retry: bool = True, check_login: bool = True) → Tuple[locust.clients.HttpSession, requests.models.Response]
post_page(uri: str, payload: Any = {}, headers: Dict[str, Any] = None, label: str = None, files: dict = None, check_login: bool = True) → requests.models.Response

Given a uri, executes POST request and returns response

Parameters:
  • uri – API URI to be called

  • payload – Body of the API request. Can be either JSON or text input to allow for different payload types.

  • headers – header for the REST API Call

  • label – the label to be displayed by locust

Returns: Json response of post operation

refresh_after_record_action(post_url: str, record_action_component: Dict[str, Any], record_action_trigger_component: Dict[str, Any], context: Dict[str, Any], uuid: str, label: str = None) → Dict[str, Any]

Calls the post operation to refresh a form after completion of a record action

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • record_action_component – the JSON representing the relevant record action component

  • record_action_trigger_component – the JSON representing the form’s record action trigger component

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

Returns: the response of post operation as json

replace_base_path_if_appropriate(uri: str) → str
select_checkbox_item(post_url: str, checkbox: Dict[str, Any], context: Dict[str, Any], uuid: str, indices: list, context_label: str = None) → Dict[str, Any]

Calls the post operation to send an update to a checkbox to check all appropriate boxes

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • checkbox – the JSON representing the desired checkbox

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • indices – indices of the checkbox

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

Returns: the response of post operation as json

select_pickerfield_suggestion(post_url: str, picker_field: Dict[str, Any], selection: Dict[str, Any], context: Dict[str, Any], uuid: str, label: str = None) → Dict[str, Any]

Select a Picker field from available selections :param post_url: the url (not including the host and domain) to post to :param picker_field: the text field component returned from find_component_by_attribute_in_dict :param selection: the suggested item to select for the picker field :param context: the SAIL context parsed from the json response :param uuid: the uuid parsed from the json response :param label: the label to be displayed by locust for this action

Returns: the response of post operation as json

select_radio_button(post_url: str, buttons: Dict[str, Any], context: Dict[str, Any], uuid: str, index: int, context_label: str = None) → Dict[str, Any]

Calls the post operation to send an update to a radio button to select the appropriate button

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • buttons – the JSON representing the desired radio button field

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • index – index of the button to be selected

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

Returns: the response of post operation as json

send_dropdown_update(post_url: str, dropdown: Dict[str, Any], context: Dict[str, Any], uuid: str, index: int, label: str = None, url_stub: str = None) → Dict[str, Any]

Calls the post operation to send an update to a dropdown

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • dropdown – the JSON code for the desired dropdown

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • index – location of the dropdown value

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

  • url_stub – the URL stub for the page; only required to interact with user filter dropdowns on a record list

Returns: the response of post operation as json

send_multiple_dropdown_update(post_url: str, multi_dropdown: Dict[str, Any], context: Dict[str, Any], uuid: str, index: List[int], label: str = None, url_stub: str = None) → Dict[str, Any]

Calls the post operation to send an update to a multiple dropdown

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • dropdown – the JSON code for the desired dropdown

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • index – locations of the multiple dropdown value

  • label – the label to be displayed by locust for this action

  • headers – header for the REST API call

  • url_stub – the URL stub for the page; only required to interact with user filter dropdowns on a record list

Returns: the response of post operation as json

set_user_agent_to_desktop() → None
set_user_agent_to_mobile() → None
setup_content_headers() → dict
setup_feed_headers() → dict
setup_request_headers(uri: str = None) → dict

Generates standard headers for session

Parameters:

uri (str) – URI to be assigned as the Referer

Returns (dict): headers

Examples

>>> self.appian.interactor.setup_request_headers()
setup_sail_headers() → dict
update_date_field(post_url: str, date_field_component: Dict[str, Any], date_input: datetime.date, context: Dict[str, Any], uuid: str, locust_label: str = None) → Dict[str, Any]

Calls the post operation to update a date field

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • date_field_component – the JSON representing the date field component

  • date_input – date field to convert to proper text format

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

Returns: the response of post operation as json

update_datetime_field(post_url: str, datetime_field: Dict[str, Any], datetime_input: datetime.datetime, context: Dict[str, Any], uuid: str, locust_label: str = None) → Dict[str, Any]

Calls the post operation to update a date field

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • datetime_field – the JSON representing the datetime field to edit

  • datetime_input – datetime field to convert to the proper text format

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

Returns: the response of post operation as json

update_grid_from_sail_form(post_url: str, grid_component: Dict[str, Any], new_grid_save_value: Dict[str, Any], context: Dict[str, Any], uuid: str, context_label: str = None) → Dict[str, Any]

Calls the post operation to send a grid update

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • grid_component – the JSON dict representing the grid to update

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • uuid – indices of the checkbox

  • context_label – the label to be displayed by locust for this action

Returns: the response of post operation as jso

upload_document_to_field(post_url: str, upload_field: Dict[str, Any], context: Dict[str, Any], uuid: str, doc_id: Union[int, List[int]], locust_label: str = None, client_mode: str = 'DESIGN') → Dict[str, Any]

Calls the post operation to send an update to a upload_field to upload a document or list thereof. Requires a previously uploaded document id or ids

Parameters:
  • post_url – the url (not including the host and domain) to post to

  • upload_field – the JSON representing the desired checkbox

  • context – the Sail context parsed from the json response

  • uuid – the uuid parsed from the json response

  • doc_id – document id or list of document ids for the upload

  • context_label – the label to be displayed by locust for this action

  • client_mode – where this is being uploaded to, defaults to DESIGN

Returns: the response of post operation as json

upload_document_to_server(file_path: str, is_encrypted: bool = False) → int
write_response_to_lib_folder(label: Optional[str], response: requests.models.Response) → None

Used for internal testing, to grab the response and put it in a file of type JSON

Parameters:
  • label (Optional[str]) – Optional label, used to name the file

  • response (Response) – Response object to write to a file

Writes to a recorded_responses folder from wherever you run locust