_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)

Bases: object

_get_record_instance_list_url_stub(post_url: str) → Optional[str]

Given post_url, returns the URL stub IF the url matches the url for a record instance list. If, not returns None.

Parameters

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

Returns: The url stub if post_url matches a record instance list url, otherwise None

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

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

Use this function to interact with related action links, which start a process and return the start form. :param component: the JSON representing the Related Action Link :param record_type_stub: record type stub for the record :param opaque_record_id: opaque id for the record :param opaque_related_action_id: opaque id for the related action :param locust_request_label: label to be used within locust

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

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

login(auth: list = None) → 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

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) → 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

Returns: the response of post operation as json

set_user_agent_to_desktop() → None
set_user_agent_to_mobile() → None
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.setup_request_headers()
setup_sail_headers() → dict
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: 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. Requires a previously uploaded document id

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

  • 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