Webapp Internal

class tir.technologies.webapp_internal.WebappInternal(config_path='', autostart=True)

Internal implementation of Protheus Webapp class.

This class contains all the methods defined to run Selenium Interface Tests on Protheus Webapp.

Internal methods should have the [Internal] tag and should not be accessible to the user.

Parameters
  • config_path (str) – The path to the config file. - Default: “” (empty string)

  • autostart – Sets whether TIR should open browser and execute from the start. - Default: True

Type

bool

Usage:

>>> # Inside __init__ method in Webapp class of main.py
>>> def __init__(self, config_path="", autostart=True):
>>>     self.__webapp = WebappInternal(config_path, autostart)
AddParameter(parameter, branch, portuguese_value, english_value='', spanish_value='')

Adds a parameter to the queue of parameters to be set by SetParameters method.

Parameters
  • parameter (str) – The parameter name.

  • branch (str) – The branch to be filled in parameter edit screen.

  • portuguese_value (str) – The value for a portuguese repository.

  • english_value (str) – The value for an english repository.

  • spanish_value (str) – The value for a spanish repository.

Usage:

>>> # Calling the method:
>>> oHelper.AddParameter("MV_MVCSA1", "", ".F.", ".F.", ".F.")
ChangeEnvironment(date='', group='', branch='', module='')

Clicks on the change environment area of Protheus Webapp and fills the environment screen.

Parameters
  • date (str) – The date to fill on the environment screen. - Default: “” (empty string)

  • group (str) – The group to fill on the environment screen. - Default: “” (empty string)

  • branch (str) – The branch to fill on the environment screen. - Default: “” (empty string)

  • module (str) – The module to fill on the environment screen. - Default: “” (empty string)

Usage:

>>> # Calling the method:
>>> oHelper.ChangeEnvironment(date="13/11/2018", group="T1", branch="D MG 01 ")
CheckHelp(text, button)

Checks if some help screen is present in the screen at the time and takes an action.

Parameters
  • text (str) – Text to be checked.

  • button (str) – Button to be clicked.

Usage:

>>> # Calling the method.
>>> oHelper.CheckHelp("EXISTCLI Problema: Não pode haver mais...", "Fechar")
CheckResult(field, user_value, grid=False, line=1, grid_number=1, name_attr=False)

Checks if a field has the value the user expects.

Parameters
  • field (str) – The field or label of a field that must be checked.

  • user_value (str) – The value that the field is expected to contain.

  • grid (bool) – Boolean if this is a grid field or not. - Default: False

  • line (int) – Grid line that contains the column field to be checked.- Default: 1

  • grid_number (int) – Grid number of which grid should be checked when there are multiple grids on the same screen. - Default: 1

  • name_attr (bool) – Boolean if search by Name attribute must be forced. - Default: False

Usage:

>>> # Calling method to check a value of a field:
>>> oHelper.CheckResult("A1_COD", "000001")
>>> #-----------------------------------------
>>> # Calling method to check a field that is on the second line of a grid:
>>> oHelper.CheckResult("Client", "000001", grid=True, line=2)
>>> oHelper.LoadGrid()
>>> #-----------------------------------------
>>> # Calling method to check a field that is on the second grid of the screen:
>>> oHelper.CheckResult("Order", "000001", grid=True, line=1, grid_number=2)
>>> oHelper.LoadGrid()
CheckView(text, element_type='help')

Checks if a certain text is present in the screen at the time and takes an action.

“help” - alerts with messages of errors.

Parameters
  • text (str) – Text to be checked.

  • element_type (str) – Type of element. - Default: “help”

Usage:

>>> # Calling the method.
>>> oHelper.CheckView("Processing")
ClickBox(field, content_list='', select_all=False, grid_number=1)

Clicks on Checkbox elements of a grid.

Parameters
  • field (str) – The column to identify grid rows.

  • content_list (str) – Comma divided string with values that must be checked. - Default: “” (empty string)

  • select_all (bool) – Boolean if all options should be selected. - Default: False

  • grid_number (int) – Which grid should be used when there are multiple grids on the same screen. - Default: 1

Usage:

>>> # Calling the method to select a specific checkbox:
>>> oHelper.ClickBox("Branch", "D MG 01 ")
>>> #--------------------------------------------------
>>> # Calling the method to select multiple checkboxes:
>>> oHelper.ClickBox("Branch", "D MG 01 , D RJ 02")
>>> #--------------------------------------------------
>>> # Calling the method to select all checkboxes:
>>> oHelper.ClickBox("Branch", select_all=True)
ClickCheckBox(label_box_name, position=1)

Clicks on a Label in box on the screen.

Parameters
  • label_box_name (str) – The label box name

  • position (int) – position label box on interface

Usage:

>>> # Call the method:
>>> oHelper.ClickCheckBox("Search",1)
ClickFolder(folder_name)

Clicks on folder elements on the screen.

Parameters

folder_name (str) – Which folder item should be clicked.

Usage:

>>> # Calling the method:
>>> oHelper.ClickFolder("Folder1")
ClickGridCell(column, row_number=1, grid_number=1)

Clicks on a Cell of a Grid.

Parameters
  • column (str) – The column that should be clicked.

  • row_number (int) – Grid line that contains the column field to be checked.- Default: 1

  • grid_number (int) – Grid number of which grid should be checked when there are multiple grids on the same screen. - Default: 1

Usage:

>>> # Calling the method:
>>> oHelper.ClickGridCell("Product", 1)
ClickIcon(icon_text)

Clicks on an Icon button based on its tooltip text.

Parameters

icon_text (str) – The tooltip text.

Usage:

>>> # Call the method:
>>> oHelper.ClickIcon("Add")
>>> oHelper.ClickIcon("Edit")
ClickLabel(label_name)

Clicks on a Label on the screen.

Parameters

label_name (str) – The label name

Usage:

>>> # Call the method:
>>> oHelper.ClickLabel("Search")
ClickMenuPopUpItem(label, right_click)

Clicks on MenuPopUp Item based in a text

Parameters
  • text (str) – Text in MenuPopUp to be clicked.

  • right_click – Button to be clicked.

Usage:

>>> # Calling the method.
>>> oHelper.ClickMenuPopUpItem("Label")
ClickTree(treepath, right_click=False)

Clicks on TreeView component.

Parameters

treepath – String that contains the access path for the item separate by “>” .

Usage:

>>> # Calling the method:
>>> oHelper.ClickTree("element 1 > element 2 > element 3")
Finish()

Exit the protheus Webapp.

Usage:

>>> # Calling the method.
>>> oHelper.Finish()
GetText(string_left='', string_right='')

This method returns a string from modal based on the string in the left or right position that you send on parameter.

If the string_left was filled then the right side content is return.

If the string_right was filled then the left side content is return.

If no parameter was filled so the full content is return.

Parameters
  • string_left (str) – String of the left side of content.

  • string_right (str) – String of the right side of content.

Usage:

>>> # Calling the method:
>>> oHelper.GetText(string_left="Left Text", string_right="Right Text")
>>> oHelper.GetText(string_left="Left Text")
>>> oHelper.GetText()
GetValue(field, grid=False, line=1, grid_number=1)

Gets the current value or text of element.

Parameters
  • field (str) – The field or label of a field that must be checked.

  • grid (bool) – Boolean if this is a grid field or not. - Default: False

  • line (int) – Grid line that contains the column field to be checked.- Default: 1

  • grid_number (int) – Grid number of which grid should be checked when there are multiple grids on the same screen. - Default: 1

Usage:

>>> # Calling the method:
>>> current_value = oHelper.GetValue("A1_COD")
LoadGrid()

This method is responsible for running all actions of the input and check queues of a grid. After running, the queues would be empty.

Must be called after SetValue and CheckResult calls that has the grid parameter set to True.

Usage:

>>> # After SetValue:
>>> oHelper.SetValue("A1_COD", "000001", grid=True)
>>> oHelper.LoadGrid()
>>> #--------------------------------------
>>> # After CheckResult:
>>> oHelper.CheckResult("A1_COD", "000001", grid=True, line=1)
>>> oHelper.LoadGrid()
LogOff()

Logs out of the Protheus Webapp.

Usage:

>>> # Calling the method.
>>> oHelper.LogOff()
MessageBoxClick(button_text)

Clicks on desired button inside a Messagebox element.

Parameters

button_text (str) – Desired button to click.

Usage:

>>> # Calling the method:
>>> oHelper.MessageBoxClick("Ok")
Program(program_name)

Method that sets the program in the initial menu search field.

Note

Only used when the Initial Program is the module Ex: SIGAFAT.

Parameters

program_name (str) – The program name

Usage:

>>> # Calling the method:
>>> oHelper.Program("MATA020")
RestoreParameters()

Restores parameters to previous value in CFG screen. Should be used after a SetParameters call.

Usage:

>>> # Adding Parameter:
>>> oHelper.AddParameter("MV_MVCSA1", "", ".F.", ".F.", ".F.")
>>> # Calling the method:
>>> oHelper.SetParameters()
ScrollGrid(column, match_value, grid_number=1)

Scrolls Grid until a matching column is found.

Parameters
  • field (str) – The column to be matched.

  • match_value (str) – The value to be matched in defined column.

  • grid_number (int) – Which grid should be used when there are multiple grids on the same screen. - Default: 1

Usage:

>>> # Calling the method to scroll to a column match:
>>> oHelper.ScrollGrid(column="Branch",match_value="D MG 01 ")
>>> #--------------------------------------------------
>>> # Calling the method to scroll to a column match of the second grid:
>>> oHelper.ScrollGrid(column="Branch", match_value="D MG 01 ", grid_number=2)
SearchBrowse(term, key=None, identifier=None, index=False)

Searchs a term on Protheus Webapp.

It will search using the default search key, but if a key is provided it will search using the chosen key.

It will search using the first search box on the screen, but if an identifier is provided, it will search on the chosen search box.

Parameters
  • term (str) – The term that must be searched.

  • key (str) – The search key to be chosen on the search dropdown. - Default: None

  • identifier (str) – The identifier of the search box. If none is provided, it defaults to the first of the screen. - Default: None

  • index (bool) – Whether the key is an index or not. - Default: False

Usage:

>>> # To search using the first search box and default search key:
>>> oHelper.SearchBrowse("D MG 001")
>>> #------------------------------------------------------------------------
>>> # To search using the first search box and a chosen key:
>>> oHelper.SearchBrowse("D MG 001", key="Branch+id")
>>> #------------------------------------------------------------------------
>>> # To search using a chosen search box and the default search key:
>>> oHelper.SearchBrowse("D MG 001", identifier="Products")
>>> #------------------------------------------------------------------------
>>> # To search using a chosen search box and a chosen search key:
>>> oHelper.SearchBrowse("D MG 001", key="Branch+id", identifier="Products")
SetBranch(branch)

Chooses the branch on the branch selection screen.

Parameters

branch (str) – The branch that would be chosen.

Usage:

>>> # Calling the method:
>>> oHelper.SetBranch("D MG 01 ")
SetButton(button, sub_item='', position=1, check_error=True)

Method that clicks on a button on the screen.

Parameters
  • button (str) – Button to be clicked.

  • sub_item (str) – Sub item to be clicked inside the first button. - Default: “” (empty string)

  • position (int) – Position which element is located. - Default: 1

Usage:

>>> # Calling the method to click on a regular button:
>>> oHelper.SetButton("Add")
>>> #-------------------------------------------------
>>> # Calling the method to click on a sub item inside a button.
>>> oHelper.SetButton("Other Actions", "Process")
>>> #-------------------------------------------------
>>> # Calling the method to click on a sub item inside a button, this form is an alternative.
>>> oHelper.SetButton("Other Actions", "Process, Process_02, Process_03") 
SetFilePath(value)

Fills the path screen with desired path.

Parameters

value (str) – Path to be inputted.

Usage:

>>> # Calling the method:
>>> oHelper.SetFilePath(r"C:\folder")
SetFocus(field, grid_cell, row_number)

Sets the current focus on the desired field.

Parameters

field (str) – The field that must receive the focus.

Usage:

>>> # Calling the method:
>>> oHelper.SetFocus("A1_COD")
>>> oHelper.SetFocus("A1_COD", grid_cell = True)
SetKey(key, grid=False, grid_number=1, additional_key='')

Press the desired key on the keyboard on the focused element.

Note

If this methods is the first to be called, we strongly recommend using some wait methods like WaitShow().

Supported keys: F1 to F12, CTRL+Key, ALT+Key, Up, Down, Left, Right, ESC, Enter and Delete

Parameters
  • key (str) – Key that would be pressed

  • grid (bool) – Boolean if action must be applied on a grid. (Usually with DOWN key)

  • grid_number (int) – Which grid should be used when there are multiple grids on the same screen. - Default: 1

  • additional_key (str) – Key additional that would be pressed.

Usage:

>>> # Calling the method:
>>> oHelper.SetKey("ENTER")
>>> #--------------------------------------
>>> # Calling the method on a grid:
>>> oHelper.SetKey("DOWN", grid=True)
>>> #--------------------------------------
>>> # Calling the method on the second grid on the screen:
>>> oHelper.SetKey("DOWN", grid=True, grid_number=2)
SetLateralMenu(menu_itens, save_input=True)

Navigates through the lateral menu using provided menu path. e.g. “MenuItem1 > MenuItem2 > MenuItem3”

Parameters
  • menu_itens (str) – String with the path to the menu.

  • save_input (bool) – Boolean if all input info should be saved for later usage. Leave this flag ‘True’ if you are not sure. Default: True

Usage:

>>> # Calling the method:
>>> oHelper.SetLateralMenu("Updates > Registers > Products > Groups")
SetParameters()

Sets the parameters in CFG screen. The parameters must be passed with calls for AddParameter method.

Usage:

>>> # Adding Parameter:
>>> oHelper.AddParameter("MV_MVCSA1", "", ".F.", ".F.", ".F.")
>>> # Calling the method:
>>> oHelper.SetParameters()
SetTabEDAPP(table)

Chooses the table on the generic query (EDAPP).

Parameters

table (str) – The table that would be chosen.

Usage:

>>> # Calling the method:
>>> oHelper.SetTabEDAPP("AAB")
SetValue(field, value, grid=False, grid_number=1, ignore_case=True, row=None, name_attr=False, position=1)

Sets value of an input element.

Note

Attention on the grid use the field mask.

Parameters
  • field (str) – The field name or label to receive the value

  • value (str or bool) – The value to be inputted on the element.

  • grid (bool) – Boolean if this is a grid field or not. - Default: False

  • grid_number (int) – Grid number of which grid should be inputted when there are multiple grids on the same screen. - Default: 1

  • ignore_case (bool) – Boolean if case should be ignored or not. - Default: True

  • row (int) – Row number that will be filled

  • name_attr (bool) – Boolean if search by Name attribute must be forced. - Default: False

Usage:

>>> # Calling method to input value on a field:
>>> oHelper.SetValue("A1_COD", "000001")
>>> #-----------------------------------------
>>> # Calling method to input value on a field that is a grid:
>>> oHelper.SetValue("Client", "000001", grid=True)
>>> oHelper.LoadGrid()
>>> #-----------------------------------------
>>> # Calling method to checkbox value on a field that is a grid:
>>> oHelper.SetValue('Confirmado?', True, grid=True)
>>> oHelper.LoadGrid()
>>> #-----------------------------------------
>>> # Calling method to input value on a field that is on the second grid of the screen:
>>> oHelper.SetValue("Order", "000001", grid=True, grid_number=2)
>>> oHelper.LoadGrid()
Setup(initial_program, date='', group='99', branch='01', module='', save_input=True)

Prepare the Protheus Webapp for the test case, filling the needed information to access the environment.

Parameters
  • initial_program (str) – The initial program to load.

  • date (str) – The date to fill on the environment screen. - Default: “” (empty string)

  • group (str) – The group to fill on the environment screen. - Default: “99”

  • branch (str) – The branch to fill on the environment screen. - Default: “01”

  • module (str) – The module to fill on the environment screen. - Default: “” (empty string)

  • save_input (bool) – Boolean if all input info should be saved for later usage. Leave this flag ‘True’ if you are not sure. Default: True

Usage:

>>> # Calling the method:
>>> oHelper.Setup("SIGAFAT", "18/08/2018", "T1", "D MG 01 ")
TearDown()

Closes the webdriver and ends the test case.

Usage:

>>> #Calling the method
>>> self.TearDown()
WaitFieldValue(field, expected_value)

Wait until field has expected value. Recommended for Trigger fields.

Parameters
  • field (str) – The desired field.

  • expected_value (str) – The expected value.

Usage:

>>> # Calling method:
>>> self.WaitFieldValue("CN0_DESCRI", "MY DESCRIPTION")
WaitHide(string, timeout=None)

Search string that was sent and wait hide the element.

Parameters

string (str) – String that will hold the wait.

Usage:

>>> # Calling the method:
>>> oHelper.WaitHide("Processing")
WaitProcessing(itens, timeout=None)

Uses WaitShow and WaitHide to Wait a Processing screen

Parameters

itens (str) – List of itens that will hold the wait.

Usage:

>>> # Calling the method:
>>> oHelper.WaitProcessing("Processing")
WaitShow(string, timeout=None)

Search string that was sent and wait show the elements.

Parameters

string (str) – String that will hold the wait.

Usage:

>>> # Calling the method:
>>> oHelper.WaitShow("Processing")
add_grid_row_counter(grid)

[Internal]

Adds the counter of rows to the global dictionary.

Parameters

grid (BeautifulSoup object.) – The grid whose rows are being controlled.

Usage:

>>> # Calling the method:
>>> self.add_grid_row_counter(grid)
assert_result(expected)

[Internal]

Asserts the result based on the expected value.

Parameters

expected (bool) – Expected value

Usage :

>>> #Calling the method:
>>> self.assert_result(True)
check_element_tooltip(element, expected_text)

[Internal]

Internal method of ClickIcon.

Fires the MouseOver event of an element, checks tooltip text, fires the MouseOut event and returns a boolean whether the tooltip has the expected text value or not.

Parameters
  • element (BeautifulSoup object) – The target element object.

  • expected_text (str) – The text that is expected to exist in button’s tooltip.

Returns

Boolean value whether element has tooltip text or not.

Return type

bool

Usage:

>>> # Call the method:
>>> has_add_text = self.check_element_tooltip(button_object, "Add")
check_grid(field, x3_dictionaries, get_value=False)

[Internal]

Checks the grid cell with the passed parameters.

Parameters
  • field (List of values) – An item from the grid’s check queue

  • x3_dictionaries (Tuple of dictionaries) – Tuple of dictionaries containing information extracted from x3.

  • get_value (bool) – Boolean value if check_grid should return its value.

Returns

If get_value flag is True, it will return the captured value.

Return type

str

Usage:

>>> # Calling the method:
>>> self.check_grid([0, "A1_COD", "000001", 0], x3_dictionaries, False)
check_grid_appender(line, column, value, grid_number=0)

[Internal]

Adds a value to the check queue of a grid.

Parameters
  • line (int) – The line of the grid that would be checked.

  • column (str) – The column of the grid that would be checked.

  • value (str) – The value that is expected.

  • grid_number (int) – Which grid should be used when there are multiple grids on the same screen. - Default: 0

Usage:

>>> # Calling the method:
>>> self.check_grid_appender(0,"A1_COD", "000001", 0)
check_mask(element)

[Internal]

Checks whether the element has a mask or not.

Parameters

element (Selenium object) – The element that must be checked.

Returns

Boolean if element has a mask or not.

Return type

bool

Usage:

>>> # Calling the method:
>>> self.check_mask(my_element)
check_toggler(label_filtered)

[Internal]

children_element_count(element_selector, children_selector)

[Internal]

Returns the count of elements of a certain CSS Selector that exists within a certain element located also via CSS Selector.

Parameters
  • element_selector (str) – The selector to find the first element.

  • children_selector (str) – The selector to find the children elements inside of the first element.

Returns

The count of elements matching the children_selector inside of element_selector.

Return type

int

Usage:

>>> # Calling the method:
>>> self.children_element_count(".tmenu", ".tmenuitem")
clear_grid()

[Internal]

Empties the global grid list variables.

Usage:

>>> # Calling the method:
>>> self.clear_grid()
click_check_radio_button(field, value, name_attr=False, position=1)

[Internal] Identify and click on check or radio button.

Parameters
  • field (str) – The field that would receive the input.

  • value (bool) – The value that must be on the checkbox or grid.

Returns

The element that changed value.

Return type

Selenium object

Usage:

>>> # Calling the method:
>>> element = self.check_checkbox("CheckBox1", True)
click_sub_menu(sub_item)

[Internal]

Clicks on the sub menu of buttons. Returns True if succeeded. Internal method of SetButton.

Parameters

sub_item (str) – The menu item that should be clicked.

Returns

Boolean if click was successful.

Return type

bool

Usage:

>>> # Calling the method:
>>> self.click_sub_menu("Process")
click_tree(label, last_item, right_click)

[Internal] Take treenode and label to filter and click in the toggler element to expand the TreeView.

clicktree_status_selected(label_filtered, check_expanded=False)

[Internal]

close_coin_screen()

[Internal]

Closes the coin screen.

Usage:

>>> # Calling the method:
>>> self.close_coin_screen()
close_modal()

[Internal]

This method closes the modal in the opening screen.

Usage:

>>> # Calling the method:
>>> self.close_modal()
close_resolution_screen()

[Internal]

Closes the Alert of resolution screen.

Usage:

>>> # Calling the method:
>>> self.close_resolution_screen()
containers_filter(containers)

[Internal] Filter and remove tsvg class an return a container_filtered

Usage:

>>> #Calling the method
>>> containers = self.containers_filter(containers)
create_message(args, message_type=<MessageType.CORRECT: 1>)

[Internal]

Returns default messages used all throughout the class based on input parameters.

Each message type has a different number of placeholders to be passed as a list through args parameter:

Correct Message = “{} Value of field {} is correct!” - 2 placeholders

Incorrect Message = “{} Value expected for field “{}” ({}) is not equal to what was found ({}).” - 3 placeholders

Disabled Message = “{} Field “{}” is disabled.” - 2 placeholders

AssertError Message = “Failed: Value expected for field {}: “{}” is different from what was found “{}”.” - 2 placeholders

Parameters
  • args (List of str) – A list of strings to be replaced in each message.

  • message_type (enum.MessageType) – Enum of which message type should be created. - Default: enum.MessageType.Correct

Usage:

>>> # Calling the method:
>>> message = self.create_message([txtaux, field, user_value, captured_value], enum.MessageType.INCORRECT)
create_x3_tuple()

[Internal]

Returns a tuple of dictionaries of field information based on all fields in the grid queues.

Returns

A tuple containing the needed x3 information.

Return type

Tuple of Dictionaries

Usage:

>>> # Calling the method:
>>> x3_dictionaries = self.create_x3_tuple()
element_exists(term, scrap_type=<ScrapType.TEXT: 1>, position=0, optional_term='', main_container='.tmodaldialog, .ui-dialog', check_error=True)

[Internal]

Returns a boolean if element exists on the screen.

Parameters
  • term (str) – The first term to use on a search of element

  • scrap_type (enum.ScrapType) – Type of element search. - Default: enum.ScrapType.TEXT

  • position (int) – Position which element is located. - Default: 0

  • optional_term (str) – Second term to use on a search of element. Used in MIXED search. - Default: “” (empty string)

Returns

True if element is present. False if element is not present.

Return type

bool

Usage:

>>> element_is_present = element_exists(term=".ui-dialog", scrap_type=enum.ScrapType.CSS_SELECTOR)
>>> element_is_present = element_exists(term=".tmodaldialog.twidget", scrap_type=enum.ScrapType.CSS_SELECTOR, position=initial_layer+1)
>>> element_is_present = element_exists(term=text, scrap_type=enum.ScrapType.MIXED, optional_term=".tsay")
environment_screen(change_env=False)

[Internal]

Fills the environment screen of Protheus with the values passed on the Setup method. Used to fill the fields triggered by the ChangeEnvironment method as well.

Parameters

change_env (bool) – Boolean if the method is being called by ChangeEnvironment. - Default: False

Usage:

>>> # Calling the method
>>> self.environment_screen()
fill_grid(field, x3_dictionaries, initial_layer)

[Internal]

Fills the grid cell with the passed parameters.

Parameters
  • field (List of values) – An item from the grid’s input queue

  • x3_dictionaries (Tuple of dictionaries) – Tuple of dictionaries containing information extracted from x3.

  • initial_layer (int) – The initial layer of elements of Protheus Webapp

Usage:

>>> # Calling the method:
>>> self.fill_grid(["A1_COD", "000001", 0, False], x3_dictionaries, 0)
fill_parameters(restore_backup)

[Internal]

Internal method of fill_parameters. Searches and edits all parameters in the queue.

Parameters

restore_backup (bool) – Boolean if method should restore the parameters.

Usage:

>>> # Calling the method:
>>> self.fill_parameters(restore_backup=False)
fill_search_browse(term, search_elements)

[Internal]

Fills search input method and presses the search button.

Parameters
  • term (str) – The term to be searched

  • search_elements (Tuple of Beautiful Soup objects) – Tuple of Search elements

Usage:

>>> #Preparing the tuple:
>>> search_elements = self.get_search_browse_elements("Products")
>>> # Calling the method:
>>> self.fill_search_browse("D MG 01", search_elements)
filter_by_tooltip_value(element_list, expected_text)

[Internal]

Filters elements by finding the tooltip value that is shown when mouseover event is triggered.

Parameters
  • element_list (Beautiful Soup object list) – The list to be filtered

  • expected_text (str) – The expected tooltip text.

Returns

The filtered list of elements.

Return type

Beautiful Soup object list

Usage:

>>> # Calling the method:
>>> filtered_elements = self.filter_by_tooltip_value(my_element_list, "Edit")
filter_is_displayed(elements)

[Internal] Returns only displayed elements.

Usage:

>>> #Calling the method
>>> elements = self.filter_is_displayed(elements)
filter_label_element(label_text, container)

[Internal] Filter and remove a specified character with regex, return only displayed elements if > 1.

Usage:

>>> #Calling the method
>>> elements = self.filter_label_element(label_text, container)
find_label_element(label_text, container=None, position=1)

[Internal]

Find input element next to label containing the label_text parameter.

Parameters
  • label_text (str) – The label text to be searched

  • container (BeautifulSoup object) – The main container object to be used

Returns

A list containing a BeautifulSoup object next to the label

Return type

List of BeautifulSoup objects

Usage:

>>> self.find_label_element("User:", container_object)
find_sub_menu_child(sub_item, containers)

[Internal]

Finds the menu item inside child menu layers.

Parameters
  • sub_item (str) – The menu item that should be clicked.

  • containers (List of Beautiful Soup objects) – The menu itens of the current layer that have children.

Returns

The item that was found. If None was found, it returns an empty string.

Return type

Selenium object

Usage:

>>> # Calling the method:
>>> item = self.find_sub_menu_child("Process", container_list)
find_sub_menu_text(menu_item, current_itens)

[Internal]

Returns a tuple containing a possible match of a menu item among the current itens. If none was found it will be an empty string.

The second position will contain the itens that have children itens. If none has children itens, it will be an empty list.

Parameters
  • menu_item (str) – The menu item that should be clicked.

  • current_item (List of Selenium objects.) – The menu itens in the current layer.

Returns

Tuple containing a possible match of a menu item and the itens that have children itens.

Return type

Tuple (selenium object, list of selenium objects)

Usage:

>>> # Calling the method:
>>> result = self.find_sub_menu_text(item, child_itens)
find_tree_bs(label)

[Internal]

Search the label string in current container and return a treenode element.

generate_regex_by_prefixes(prefixes)

[Internal]

Returns a regex string created by combining all field prefixes.

Parameters

prefixes (List of str) – Prefixes of fields to be combined in a regex.

Usage:

>>> # Calling the method:
>>> regex = self.generate_regex_by_prefixes(field_prefixes)
get_current_container()

[Internal]

An internal method designed to get the current container. Returns the BeautifulSoup object that represents this container or NONE if nothing is found.

Returns

The container object

Return type

BeautifulSoup object

Usage:

>>> # Calling the method:
>>> container = self.get_current_container()
get_distance(label_pos, element_pos)

[internal]

get_element_size(id)

Internal Return Height/Width

get_enchoice_button_ids(layer)

[Internal]

If current layer level has an enchoice, returns all buttons’ ids.

Parameters

layer (int) – Current layer level that the application is.

Returns

List with enchoice’s buttons’ ids.

Return type

List of str

Usage:

>>> # Calling the method:
>>> self.get_enchoice_button_ids(current_layer)
get_field(field, name_attr=False, position=1)

[Internal]

This method decides if field would be found by either it’s name or by it’s label. Internal method of input_value and CheckResult.

Parameters
  • field (str) – Field name or field label to be searched

  • name_attr (bool) – Boolean if search by Name attribute must be forced. - Default: False

Returns

Field element

Return type

Beautiful Soup object

Usage:

>>> # Calling the method:
>>> element1 = self.get_field("A1_COD")
>>> element2 = self.get_field("Product")
get_function_from_stack()

[Internal]

Gets the function name that called the Webapp class from the call stack.

Usage:

>>> # Calling the method:
>>> self.get_function_from_stack()
get_grid(grid_number=0)

[Internal] Gets a grid BeautifulSoup object from the screen.

Parameters

grid_number – The number of the grid on the screen.

Type

int

Returns

Grid BeautifulSoup object

Return type

BeautifulSoup object

Usage:

>>> # Calling the method:
>>> my_grid = self.get_grid()
get_headers_from_grids(grids)

[Internal]

Returns the headers of each grid in grids parameter.

Parameters

grids (List of BeautifulSoup objects) – The grids to extract the headers.

Returns

List of Dictionaries with each header value and index.

Return type

List of Dict

Usage:

>>> # Calling the method:
>>> headers = self.get_headers_from_grids(grids)
get_language()

[Internal]

Gets the current language of the html.

Returns

The current language of the html.

Return type

str

Usage:

>>> # Calling the method:
>>> language = self.get_language()
get_panel_name_index(panel_name)

[Internal]

Gets the index of search box element based on the panel name associated with it.

Parameters

panel_name

Returns

The index of the search box starting with 0

Return type

int

Usage:

>>> # Calling the method:
>>> index = self.get_panel_name_index("Products")
get_position_from_bs_element(element)

[Internal]

get_program_name()

[Internal]

get_search_browse_elements(panel_name=None)

[Internal]

Returns a tuple with the search browse elements in this order: Key Dropdown, Input, Icon.

Parameters

panel_name (str) – The identifier of the search box. If none is provided, it defaults to the first of the screen. - Default: None

Returns

Tuple with the Key Dropdown, Input and Icon elements of a search box

Return type

Tuple of Beautiful Soup objects.

Usage:

>>> # Calling the method:
>>> search_elements = self.get_search_browse_elements("Products")
get_selected_row(rows)

[Internal]

From a list of rows, filter the selected one.

Parameters

rows (List of Beautiful Soup objects) – List of rows.

Returns

The selected row.

Return type

Beautiful Soup object.

Usage:

>>> # Calling the method:
>>> selected_row = self.get_selected_row(rows)
get_selenium_column_element(xpath)

[Internal]

Tries to get the selenium element out of a grid column. Workaround method to be used instead of a lambda function on fill_grid method.

Parameters

xpath (str) – The xpath to the column.

Usage:

>>> #  Calling the method:
>>> self.get_selenium_column_element(xpath)
get_single_button()

[Internal]

get_text(string_left, string_right)
Parameters

string

Returns

get_text_position(text='', string_left='', string_right='')
Parameters
  • string_left

  • srting_right

Returns

get_web_value(element)

[Internal]

Gets the current value or text of element.

Parameters

element (Selenium object) – The element to get value or text from

Returns

The value or text of passed element

Return type

str

Usage:

>>> # Calling the method:
>>> current_value = self.get_web_value(selenium_field_element)
get_x3_dictionaries(fields)

[Internal]

Generates the dictionaries with field comparisons from the x3 file,

Dictionaries:Field to Type, Field to Size, Field to Title.

Parameters

fields (List of str) – List of fields that must be located in x3.

Returns

The three x3 dictionaries in a Tuple.

Trype

Tuple of Dictionary

Usage:

>>> # Calling the method:
>>> x3_dictionaries = self.get_x3_dictionaries(field_list)
input_grid_appender(column, value, grid_number=0, new=False, row=None)

[Internal]

Adds a value to the input queue of a grid.

Parameters
  • column (str) – The column of the grid that would receive the input.

  • value (str) – The value that would be inputted.

  • grid_number (int) – Which grid should be used when there are multiple grids on the same screen. - Default: 0

  • new (bool) – Boolean value if this is a new line that should be added. - Default: 1

  • row (int) – Row number that will be filled

Usage:

>>> # Calling the method:
>>> self.input_grid_appender("A1_COD", "000001", 0)
>>> # ---------------------------------------------
>>> # Calling the method for a new line:
>>> self.input_grid_appender("", "", 0, True)
input_value(field, value, ignore_case=True, name_attr=False, position=1)

[Internal]

Sets value of an input element. Returns True if succeeded, False if it failed.

Parameters
  • field (str) – The field name or label to receive the value

  • value (str) – The value to be set on the field

  • ignore_case (bool) – Boolean if case should be ignored or not. - Default: True

  • name_attr (bool) – Boolean if search by Name attribute must be forced. - Default: False

Returns

True if succeeded, False if it failed.

Return type

bool

Usage:

>>> # Calling the method
>>> self.input_value("A1_COD", "000001")
log_error(message, new_log_line=True, skip_restart=False)

[Internal]

Finishes execution of test case with an error and creates the log information for that test.

Parameters
  • message (str) – Message to be logged

  • new_log_line (bool) – Boolean value if Message should be logged as new line or not. - Default: True

Usage:

>>> #Calling the method:
>>> self.log_error("Element was not found")
log_result(field, user_value, captured_value)

[Internal]

Logs the result of comparison between user value and captured value.

Parameters
  • field (str) – The field whose values would be compared

  • user_value (str) – The value the user expects

  • captured_value (str) – The value that was captured on the screen

Usage:

>>> # Calling the method:
>>> self.log_result("A1_COD", "000001", "000001")
new_grid_line(field, add_grid_line_counter=True)

[Internal]

Creates a new line on the grid.

Parameters
  • field (List of values) – An item from the grid’s input queue

  • add_grid_line_counter (bool) – Boolean if counter should be incremented when method is called. - Default: True

Usage:

>>> # Calling the method:
>>> self.new_grid_line(["", "", 0, True])
parameter_screen(restore_backup)

[Internal]

Internal method of SetParameters and RestoreParameters.

Parameters

restore_backup (bool) – Boolean if method should restore the parameters.

Usage:

>>> # Calling the method:
>>> self.parameter_screen(restore_backup=False)
pop_dict_itens(dict_, element_id)

[Internal]

program_screen(initial_program='', environment='')

[Internal]

Fills the first screen of Protheus with the first program to run and the environment to connect.

Parameters
  • initial_program (str) – The initial program to load

  • environment (str) – The environment to connect

Usage:

>>> # Calling the method
>>> self.program_screen("SIGAADV", "MYENVIRONMENT")
remove_mask(string)

[Internal]

Removes special characters from received string.

Parameters

string (str) – The string that would have its characters removed.

Returns

The string with its special characters removed.

Return type

str

Usage:

>>> # Calling the method:
>>> value_without_mask = self.remove_mask("111-111.111")
>>> # value_without_mask == "111111111"
restart()

[Internal]

Restarts the Protheus Webapp and fills the initial screens.

Usage:

>>> # Calling the method:
>>> self.restart()
result_checkbox(field, value)

[Internal]

Checks expected value of a Checkbox element.

Parameters
  • field (str) – The field whose value would be checked.

  • value (bool) – The expected value of the radio button.

Returns

Boolean if expected value was found on the element or not.

Return type

bool

Usage:

>>> # Calling the method:
>>> assertion_value = self.result_checkbox("CheckBox1", True)
search_browse_key(search_key, search_elements, index=False)

[Internal]

Chooses the search key to be used during the search.

Parameters
  • search_key (str) – The search key to be chosen on the search dropdown

  • search_elements (Tuple of Beautiful Soup objects) – Tuple of Search elements

  • index (bool) – Whether the key is an index or not.

Usage:

>>> #Preparing the tuple:
>>> search_elements = self.get_search_browse_elements("Products")
>>> # Calling the method:
>>> self.search_browse_key("Branch+Id", search_elements)
search_element_position(field, position=1)

[Internal] Usage: >>> # Calling the method >>> self.search_element_position(field)

search_for_errors()

[Internal]

Searches for errors and alerts in the screen.

Usage:

>>> # Calling the method:
>>> self.search_for_errors()
search_text(selector, text)

[Internal] Return a element based on text and selector.

Usage:

>>> #Calling the method
>>> element = self.search_text(selector, text)
set_log_info()

[Internal] Fills the log information needed by opening the About page.

Usage:

>>> # Calling the method:
>>> self.set_log_info()
set_program(program)

[Internal]

Method that sets the program in the initial menu search field.

Parameters

program (str) – The program name

Usage:

>>> # Calling the method:
>>> self.set_program("MATA020")
standard_search_field(term, name_attr=False, send_key=False)

[Internal] Do the standard query(F3) this method 1.Search the field 2.Search icon “lookup” 3.Click()

Parameters
  • term (str) – The term that must be searched.

  • name_attr (bool) – If true searchs element by name.

  • send_key – Try open standard search field send key F3 (no click).

:type bool

Usage:

>>> # To search using a label name:
>>> self.standard_search_field(name_label)
>>> #------------------------------------------------------------------------
>>> # To search using the name of input:
>>> self.standard_search_field(field='A1_EST',name_attr=True)
>>> #------------------------------------------------------------------------
>>> # To search using the name of input and do action with a key:
>>> oHelper.F3(field='A1_EST',name_attr=True,send_key=True)
try_recover_lost_line(field, grid_id, row, headers, field_to_label)

[Internal]

Tries to recover the position if a new line is lost.

Workaround method to keep trying to get the right row fill_grid method.

Parameters
  • field (List of values) – An item from the grid’s input queue

  • grid_id (str) – The grid’s ID

  • row (Beautiful Soup object) – The current row

  • headers (List of Dictionaries) – List of dictionaries with each grid’s headers

  • field_to_label (Dict) – Dictionary from the x3 containing the field to label relationship.

Usage:

>>> # Calling the method:
>>> self.try_recover_lost_line(field, grid_id, row, headers, field_to_label)
try_send_keys(element_function, key, try_counter=0)

[Internal]

Tries to send value to element using different techniques. Meant to be used inside of a loop.

Parameters
  • element_function (function object) – The function that returns the element that would receive the value.

  • key (str or selenium.webdriver.common.keys) – The value that would be sent to the element.

  • try_counter (int) – This counter will decide which technique should be used. - Default: 0

Usage:

>>> # Calling the method:
>>> self.try_send_keys(selenium_input, user_value, try_counter)
user_screen()

[Internal]

Fills the user login screen of Protheus with the user and password located on config.json.

Usage:

>>> # Calling the method
>>> self.user_screen()
wait_blocker_ajax()

[Internal]

Wait ajax blocker disappear

wait_element(term, scrap_type=<ScrapType.TEXT: 1>, presence=True, position=0, optional_term=None, main_container='.tmodaldialog, .ui-dialog', check_error=True)

[Internal]

Waits until the desired element is located on the screen.

Parameters
  • term (str) – The first search term. A text or a selector.

  • scrap_type (enum.ScrapType.) – The type of webscraping. - Default: enum.ScrapType.TEXT

  • presence (bool) – If the element should exist or not in the screen. - Default: False

  • position (int) – If the element should exist at a specific position. e.g. The fourth button. - Default: 0

  • optional_term (str) – The second search term. A selector used in MIXED webscraping. - Default: None

  • main_container (str) – The selector of a container element that has all other elements. - Default: None

Usage:

>>> # Calling the method:
>>> self.wait_element(term=".ui-button.ui-dialog-titlebar-close[title='Close']", scrap_type=enum.ScrapType.CSS_SELECTOR)
wait_element_timeout(term, scrap_type=<ScrapType.TEXT: 1>, timeout=5.0, step=0.1, presence=True, position=0, optional_term=None, main_container='.tmodaldialog, .ui-dialog', check_error=True)

[Internal]

Waits until the desired element is located on the screen or until the timeout is met.

Parameters
  • term (str) – The first search term. A text or a selector.

  • scrap_type (enum.ScrapType.) – The type of webscraping. - Default: enum.ScrapType.TEXT

  • timeout (float) – The maximum amount of time of wait. - Default: 5.0

  • timeout – The amount of time each step should wait. - Default: 0.1

  • presence (bool) – If the element should exist or not in the screen. - Default: False

  • position (int) – If the element should exist at a specific position. e.g. The fourth button. - Default: 0

  • optional_term (str) – The second search term. A selector used in MIXED webscraping. - Default: None

  • main_container (str) – The selector of a container element that has all other elements. - Default: None

Usage:

>>> # Calling the method:
>>> self.wait_element_timeout(term=button, scrap_type=enum.ScrapType.MIXED, optional_term="button", timeout=10, step=0.1)
wait_smart_erp_environment()

[Internal]

web_scrap(term, scrap_type=<ScrapType.TEXT: 1>, optional_term=None, label=False, main_container=None, check_error=True)

[Internal]

Returns a BeautifulSoup object list based on the search parameters.

Does not support ScrapType.XPATH as scrap_type parameter value.

Parameters
  • term (str) – The first search term. A text or a selector

  • scrap_type (enum.ScrapType.) – The type of webscraping. - Default: enum.ScrapType.TEXT

  • optional_term (str) – The second search term. A selector used in MIXED webscraping. - Default: None

  • label (bool) – If the search is based on a label near the element. - Default: False

  • main_container (str) – The selector of a container element that has all other elements. - Default: None

Returns

List of BeautifulSoup4 elements based on search parameters.

Return type

List of BeautifulSoup4 objects

Usage:

>>> #All buttons
>>> buttons = self.web_scrap(term="button", scrap_type=enum.ScrapType.CSS_SELECTOR)
>>> #----------------#
>>> #Elements that contain the text "Example"
>>> example_elements = self.web_scrap(term="Example")
>>> #----------------#
>>> #Elements with class "my_class" and text "my_text"
>>> elements = self.web_scrap(term="my_text", scrap_type=ScrapType.MIXED, optional_term=".my_class")