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.")
AddProcedure(procedure, group)

Install/Desinstall a procedure in CFG to be set by SetProcedures method.

Parameters:
  • procedure – The procedure to be clicked in edit screen.

  • group – The group name.

Usage:

>>> # Calling the method:
>>> oHelper.AddProcedure("01", "T1")
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 ")
ChangeUser(user, password, initial_program='', date='', group='', branch='')

Change the user then init protheus on home page.

Parameters:
  • initial_program (str) – The initial program to load. - Default: “” (previous initial_program)

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

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

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

Usage:

>>> # Calling the method:
>>> oHelper.ChangeUser("userTest", "a", "SIGAFAT", "18/08/2018", "T1", "D MG 01 ")
>>> #------------------------------------------------------------------------
>>> # Calling the method:
>>> oHelper.ChangeUser(user="user08", password="8" )
>>> #------------------------------------------------------------------------
CheckHelp(text, button, text_help, text_problem, text_solution, verbosity)

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

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

  • text_help (str) – Only the help text will be checked.

  • text_problem (str) – Only the problem text will be checked.

  • text_solution (str) – Only the solution text will be checked.

  • button (str) – Button to be clicked.

  • verbosity (bool) – Check the text with high accuracy.

Usage:

>>> # Calling method to check all window text.
>>> oHelper.CheckHelp("TK250CADRE Problema: Essa reclamação já foi informada anteriormente. Solução: Informe uma reclamação que ainda não tenha sido cadastrada nessa tabela.", "Fechar")
>>> # Calling method to check help text only.
>>> oHelper.CheckHelp(text_help="TK250CADRE", button="Fechar")
>>> # Calling method to check problem text only.
>>> oHelper.CheckHelp(text_problem="Problema: Essa reclamação já foi informada anteriormente.", button="Fechar")
>>> # Calling method to check problem text only.
>>> oHelper.CheckHelp(text_solution="Solução: Informe uma reclamação que ainda não tenha sido cadastrada nessa tabela.", button="Fechar")
>>> # Calling the method to check only the problem text with high precision.
>>> oHelper.CheckHelp(text_problem="Problema: Essa reclamação já foi informada anteriormente.", button="Fechar", verbosity=True)
CheckResult(field, user_value, grid=False, line=1, grid_number=1, name_attr=False, input_field=True, direction=None, grid_memo_field=False, position=1, ignore_case=True)

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

  • input_field – False if the desired field is not an input type

:type bool :param direction: Desired direction to search for the element, currently accepts right and down :type str :param grid_memo_field: Boolean if this is a memo grid field. - Default: False :type grid_memo_field: bool

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()
>>> #-----------------------------------------
>>> # Call method to check a field value that is not an input field and is on the right:
>>> oHelper.CheckResult("Saldo Titulo", "100.000,00", input_field=False, direction='right')
>>> 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")
>>> #-----------------------------------------
>>> # Calling method to input value on a field that is on the second grid of the screen:
>>> oHelper.CheckView("Text",element_type=text-view)
>>> #-----------------------------------------
ClickBox(fields='', content_list='', select_all=False, grid_number=1, itens=False)

Clicks on Checkbox elements of a grid.

Parameters:
  • field (str) – Comma divided string with values that must be checked, combine with content_list.

  • 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

  • itens (bool) – Bool parameter that click in all itens based in the field and content reference.

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)
>>> #--------------------------------------------------
>>> # Calling the method to performe click based in 2 fields and contens:
>>> test_helper.ClickBox('Numero da SC, Item da SC', 'COM068, 0001')
>>> #--------------------------------------------------
>>> # Calling the method to click in all itens with this reference:
>>> test_helper.ClickBox('Numero da SC', 'COM068', itens=True)
ClickCheckBox(label_box_name, position=1, double_click=False)

Clicks on a Label in box on the screen.

Parameters:
  • label_box_name (str) – The label box name

  • position (int) – index label box on interface

  • double_click (bool) – True if a double click in element is necessary.

Usage:

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

Clicks on folder elements on the screen.

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

  • position (int) – In case of two or more folders with the same name in the screen, you could choose by position in order

Usage:

>>> # Calling the method:
>>> oHelper.ClickFolder("Folder1")
>>> # Second folder named as Folder1 in the same screen
>>> oHelper.ClickFolder("Folder1", position=2)
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)
ClickGridHeader(column=1, column_name='', grid_number=1)

Clicks on a Cell of a Grid Header.

Parameters:
  • column (int) – The column index that should be clicked.

  • column_name – The column index that should be clicked.

  • 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.ClickGridHeader(column = 1 , grid_number =  1)
>>> oHelper.ClickGridHeader(column_name = 'Código' , grid_number =  1)
>>> oHelper.ClickGridHeader(column = 1 , grid_number =  2)
ClickIcon(icon_text, position=1)

Clicks on an Icon button based on its tooltip text or Alt attribute title.

Parameters:
  • icon_text (str) – The tooltip/title text.

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

Usage:

>>> # Call the method:
>>> oHelper.ClickIcon("Add")
>>> oHelper.ClickIcon("Edit")
ClickImage(img_name, double_click=False)

Clicks in an Image button. They must be used only in case that ‘ClickIcon’ doesn’t support. :param img_name: Image to be clicked. :type img_name: src

Usage:

>>> # Call the method:
>>> oHelper.ClickImage("img_name")
>>> oHelper.ClickImage("img_name",double_click=True)
ClickLabel(label_name, position=0)

Clicks on a Label on the screen.

Parameters:

label_name (str) – The label name

Usage:

>>> # Call the method:
>>> oHelper.ClickLabel("Search")
ClickListBox(text)

Clicks on Item based in a text in a window tlistbox

Parameters:

text (str) – Text in windows to be clicked.

Usage:

>>> # Calling the method.
>>> oHelper.ClickListBox("text")
ClickMenuPopUpItem(label, right_click, position=1)

Clicks on MenuPopUp Item based in a text

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

  • right_click – Button to be clicked.

  • position (int) – index item text

Usage:

>>> # Calling the method.
>>> oHelper.ClickMenuPopUpItem("Label")
>>> # Calling the method using position.
>>> oHelper.ClickMenuPopUpItem("Label", position = 2)
ClickTree(treepath, right_click=False, position=1, tree_number=0)

Clicks on TreeView component.

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

  • right_click – Clicks with the right button of the mouse in the last element of the tree.

  • tree_number – Tree position for cases where there is more than one tree on exibits.

Usage:

>>> # Calling the method:
>>> oHelper.ClickTree("element 1 > element 2 > element 3")
>>> # Right Click example:
>>> oHelper.ClickTree("element 1 > element 2 > element 3", right_click=True)
Finish()

Exit the protheus Webapp.

Usage:

>>> # Calling the method.
>>> oHelper.Finish()
GetLineNumber(values=[], columns=[], grid_number=0)
Parameters:
  • values – values composition expected in respective columns

  • columns – reference columns used to get line

  • grid_number

Returns:

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, grid_memo_field=False, position=0)

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

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

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

Usage:

>>> # Calling the method:
>>> current_value = oHelper.GetValue("A1_COD")
GridTree(column, tree_path, right_click=False)

Clicks on Grid TreeView component.

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

  • right_click – Clicks with the right button of the mouse in the last element of the tree.

Usage:

>>> # Calling the method:
>>> oHelper.GridTree("element 1 > element 2 > element 3")
>>> # Right GridTree example:
>>> oHelper.GridTree("element 1 > element 2 > element 3", right_click=True)
LengthGridLines(grid)

Returns the length of the grid. :return:

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, column=None)

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")
>>> #------------------------------------------------------------------------
>>> # To search using the first search box and a chosen column:
>>> oHelper.SearchBrowse("D MG 001", column="Branch+id")
>>> #------------------------------------------------------------------------
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")
SetCalendar(day='', month='', year='', position=0)

Set date on Calendar without input field

Parameters:
  • day (str) – day disered

  • month (str) – month disered

  • year (str) – year disered

SetFilePath(value, button='')

Fills the path screen with the desired path

Warning

Necessary informed the button name or the program will select the current button name.

Parameters:
  • value (str) – Path to be inputted.

  • button (str) – Name button from path screen.

Usage:

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

Sets the current focus on the desired field.

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

  • grid_cell (bool) – Indicates if the element that deserve focus is on a grid.

  • row_number (int) – Number of row in case of multiples rows.

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

Usage:

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

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

Warning

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

Warning

Before using this method, set focus on any element.

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 :param additional_key: Key additional that would be pressed.) – Grid number of which grid should be used when there are multiple grids on the same screen. - Default: 1

  • wait_show (str) – String that will hold the wait after press a key.

  • step (float) – The amount of time each step should wait. - Default: 3

  • wait_change (Bool) – Bool when False it skips the wait for html changes.

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)
>>> #--------------------------------------
>>> # Call the method with WaitShow when you expect a new window or text to appear on the screen:
>>> oHelper.SetKey( key = "F12", wait_show="Parametros", step = 3 )
>>> #--------------------------------------
>>> # Calling the method with special keys (using parameter additional_key):
>>> oHelper.SetKey(key="CTRL", additional_key="A")
SetLateralMenu(menu_itens, save_input=True, click_menu_functional=False)

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()
SetProcedures(is_procedure_install=True)

Sets the procedures in CFG screen. The procedures must be passed with calls for AddProcedure method.

Usage:

Parameters:

is_procedure_install – If True will install the procedure.

>>> # Adding procedures:
>>> oHelper.AddProcedure("19", "T1")
>>> # Calling the method:
>>> oHelper.SetProcedures(is_procedure_install=True)
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, check_value=None, grid_memo_field=False, range_multiplier=None, direction=None, duplicate_fields=[])

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

  • check_value – Boolean ignore input check - Default: True

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

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

  • position – Position should be used to select an especific element when there is more than one of same

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

  • range_multiplier (int) – Integer value that refers to the distance of the label from the input object. The safe value must be between 1 to 10.

  • direction (str) – Desired direction to search for the element from a label, currently accepts right and down.

Usage:

>>> # Calling method to input value on a field:
>>> oHelper.SetValue("A1_COD", "000001")
>>> #-----------------------------------------
>>> # Calling method to input value on a field from a label text and looking an input field for a specific direction:
>>> oHelper.SetValue("Codigo", "000001", direction='right')
>>> #-----------------------------------------
>>> # 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 checkbox value on a field that isn't a grid:
>>> oHelper.SetValue('', True, name_attr=True, position=1)
>>> #-----------------------------------------
>>> # 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()
>>> #-----------------------------------------
>>> # Calling method to input value on a field that is a grid *Will not attempt to verify the entered value. Run only once.* :
>>> oHelper.SetValue("Order", "000001", grid=True, grid_number=2, check_value = False)
>>> oHelper.LoadGrid()
>>> # Calling method to input value in cases that have duplicate fields:
>>> oHelper.SetValue('Tipo Entrada' , '073', grid=True, grid_number=2, name_attr=True)
>>> self.oHelper.SetValue('Tipo Entrada' , '073', grid=True, grid_number=2, name_attr=True, duplicate_fields=['tipo entrada', 10])
>>> 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 ")
SetupTSS(initial_program='', enviroment='')

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

This method use the user and password from config.json.
Parameters:
  • initial_program (str) – The initial program to load.

  • environment (str) – The initial environment to load.

Usage:

>>> # Calling the method:
>>> oHelper.SetupTSS("TSSMANAGER", "SPED")
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, throw_error=True)

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, throw_error=True)

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, script_message)

[Internal]

Asserts the result based on the expected value.

Parameters:

expected (bool) – Expected value

Usage :

>>> #Calling the method:
>>> self.assert_result(True)
blocker_containers(soup)

Return The container index by z-index and filter if it is displayed

Parameters:

soup – soup object

Returns:

The container index by z-index and filter if it is displayed

change_environment_element_home_screen()

[Internal]

This method wait the element to perform ChangeEnvirionmentm return a soup element.

Usage:

>>> # Calling the method:
>>> self.change_environment_element_home_screen()
check_blocked_container(blocker_container_soup)
Returns:

check_combobox(element)
Parameters:

element

Returns:

Return True if the field is a combobox

check_dmp_file()

[Internal]

check_element_tooltip(element, expected_text, contains=False)

[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_file(base_file='', current_file='')
Parameters:
  • base_file

  • current_file

Returns:

check_grid(field, x3_dictionaries, get_value=False, position=0)

[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, position=1, ignore_case=True)

[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_grid_error(grid, headers, column_name, rows, columns, field)

[Internal]

check_grid_memo(element)

[Internal] :param element: :return:

check_hierarchy(label)
Parameters:

label

Returns:

True or False

check_layers(term)

[Internal]

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_mot_exec()

Check MotExec key content

Returns:

check_tmenu_screen()

[Internal]

check_toggler(label_filtered, element)

[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_button_finish(click_counter=None)

[internal]

This method is reponsible to click on button finish

click_button_logoff(click_counter=None)

[internal]

This method is reponsible to click on button finish

click_check_radio_button(field, value, name_attr=False, position=1, direction=None)

[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_grid_td(td_soup)

Click on a td element and checks if is selected

Parameters:

td (bs4 element) – The column to be matched.

>>> # Calling the method to click on td and check if is selected:
>>> oHelper.click_grid_td(td)
click_sub_menu(filtered_sub_itens)

[Internal]

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

Parameters:

filtered_sub_itens (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(treepath, right_click, position, tree_number)

[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_coin_screen_after_routine()

[internal] This method is responsible for closing the “coin screen” that opens after searching for the routine

close_modal()

[Internal]

This method closes the modal in the opening screen.

Usage:

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

[Internal]

Closes the news do programa screen.

Usage:

>>> # Calling the method:
>>> self.close_news_screen()
close_news_screen_after_routine()

[internal] This method is responsible for closing the “news screen” that opens after searching for the routine

close_process()

[Internal]

close_resolution_screen()

[Internal]

Closes the Alert of resolution screen.

Usage:

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

[Internal] Closes the warning screen.

Usage: >>> # Calling the method: >>> self.close_warning_screen()

close_warning_screen_after_routine()

[internal] This method is responsible for closing the “warning screen” that opens after searching for the routine

containers_filter(containers)

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

Usage:

>>> #Calling the method
>>> containers = self.containers_filter(containers)
create_auto_file(file='')
Parameters:

file

Returns:

create_message(args, message_type=MessageType.CORRECT)

[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()
date_format(date)
Parameters:

date

Returns:

driver_refresh()

[Internal]

Refresh the driver.

Usage:

>>> # Calling the method:
>>> self.driver_refresh()
element_exists(term, scrap_type=ScrapType.TEXT, position=0, optional_term='', main_container='.tmodaldialog,.ui-dialog,wa-text-input', check_error=True, twebview=False, second_term=None)

[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")
element_is_displayed(element=None, twebview=False)

[Internal]

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()
expand_treeGrid(column, item)

[Internal]

Search for a column and expand the tree Returns len of grid lines

expand_tree_grid_line(element_soup)

[Internal] Click on a column and send the ENTER key

fill_grid(field, x3_dictionaries, initial_layer, duplicate_fields=[])

[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)
filling_branch(shadow_root=None, container=None)

[Internal]

filling_date(shadow_root=None, container=None)

[Internal]

filling_environment(shadow_root=None, container=None)

[Internal]

filling_group(shadow_root=None, container=None)

[Internal]

filter_active_tabs(object)
Parameters:

object

Returns:

return the object if parent wa-tab-page is active else []

filter_by_direction(xy_label, width_safe, height_safe, position_list, direction=None)

[Internal]

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_dataframe(df, column, value)

[Internal]

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, position, twebview=False)

[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)
filter_not_read_only(list_objects)

[Internal]

Return: Objects List not read only

find_child_element(term, element)

Waits and find for shadow elements in a beautiful soup object and returns a list of elements found

>>> # Calling the method:
>>> find_element(".dict-tmenuitem", bs4_element)
find_label_element(label_text, container=None, position=1, input_field=True, direction=None)

[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, tree_number)

[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_active_parent_class(element=None)

Returns class list of an element’s parent

get_all_containers()

[Internal]

An internal method designed to get all containers. Returns the List of BeautifulSoup object that represents this containers or NONE if nothing is found.

Returns:

List containers object

Return type:

List BeautifulSoup object

Usage:

>>> # Calling the method:
>>> container = self.get_all_containers()
get_config_value(json_key)
Parameters:

json_key (str) – Json Key in config.json

Returns:

Json Key item in config.json

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_current_shadow_root_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_distance_x(x_label, x_element)

[Internal]

get_distance_y(y_label, y_element)

[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, input_field=True, direction=None)

[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, grid_element=None, grid_list=False)

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

Parameters:
  • grid_number – The number of the grid on the screen.

  • grid_element – Grid class name in HTML ex: “.tgrid”.

  • grid_list (bool) – Return all grids.

Type:

int

Type:

str

Returns:

Grid BeautifulSoup object

Return type:

BeautifulSoup object

Usage:

>>> # Calling the method:
>>> my_grid = self.get_grid()
get_grid_content(grid_number, grid_element)
Parameters:
  • grid_number

  • grid_element

Returns:

get_headers_from_grids(grids, column_name='', position=0, duplicate_fields=[])

[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_obscure_gridline(grid, row_num=0)

[Internal] :param grid: :param row_num: :return obscured row based in row number:

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_release()

Gets the current release of the Protheus.

Returns:

The current release of the Protheus.

Type:

str

Usage:

>>> # Calling the method:
>>> self.get_release()
>>> # Conditional with method:
>>> # Situation: Have a input that only appears in release greater than or equal to 12.1.023
>>> if self.get_release() >= '12.1.023':
>>>     self.click(element)
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_soup_select(selector)

Get a soup select object.

Parameters:

selector – Css selector

Returns:

Return a soup select object

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)
grid_dataframe(grid_number=0)

[Internal]

image_compare(img1, img2)

Returns differences between 2 images in Gray Scale.

Parameters:
  • img1 – cv2 object.

  • img2 – cv2 object

Returns:

Mean Squared Error (Matching error) between the images.

img_src_filtered(img_soup)

[Internal] Return an image source filtered.

input_grid_appender(column, value, grid_number=0, new=False, row=None, check_value=True, duplicate_fields=[], position=0, ignore_case=True)

[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, check_value=True, direction=None)

[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

  • check_value – Boolean ignore input check - Default: True

Returns:

True if succeeded, False if it failed.

Return type:

bool

Usage:

>>> # Calling the method
>>> self.input_value("A1_COD", "000001")
lenght_grid_lines(grid)

[Internal] Returns the leght of grid.

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])
on_screen_enabled(elements)

[Internal]

Returns a list if selenium displayed and enabled methods is True.

open_csv(csv_file, delimiter, column, header, filter_column, filter_value)

Returns a dictionary when the file has a header in another way returns a list The folder must be entered in the CSVPath parameter in the config.json. Ex:

Note

This method return data as a string if necessary use some method to convert data like int().

>>> config.json
>>> CSVPath : "C:\temp"
Parameters:
  • csv_file (str) – .csv file name

  • delimiter (str) – Delimiter option such like ‘;’ or ‘,’ or ‘|’

  • column (str) – To files with Header is possible return only a column by header name or Int value for no header files

  • header (bool) – Indicate with the file contains a Header or not default is Header None

  • filter_column (str or int) – Is possible to filter a specific value by column and value content, if value is int starts with number 1

  • filter_value (str) – Value used in pair with filter_column parameter

>>> # Call the method:
>>> file_csv = test_helper.OpenCSV(delimiter=";", csv_file="no_header.csv")
>>> file_csv_no_header_column = self.oHelper.OpenCSV(column=0, delimiter=";", csv_file="no_header_column.csv")
>>> file_csv_column = self.oHelper.OpenCSV(column='CAMPO', delimiter=";", csv_file="header_column.csv", header=True)
>>> file_csv_pipe = self.oHelper.OpenCSV(delimiter="|", csv_file="pipe_no_header.csv")
>>> file_csv_header = self.oHelper.OpenCSV(delimiter=";", csv_file="header.csv", header=True)
>>> file_csv_header_column = self.oHelper.OpenCSV(delimiter=";", csv_file="header.csv", header=True)
>>> file_csv_header_pipe = self.oHelper.OpenCSV(delimiter="|", csv_file="pipe_header.csv", header=True)
>>> file_csv_header_filter = self.oHelper.OpenCSV(delimiter=";", csv_file="header.csv", header=True, filter_column='CAMPO', filter_value='A00_FILIAL')
>>> file_csv _no_header_filter = self.oHelper.OpenCSV(delimiter=";", csv_file="no_header.csv", filter_column=0, filter_value='A00_FILIAL')
open_url_coverage(url='', initial_program='', environment='')

[Internal] Open a webapp url with line parameters :param url: server url. :type url: str :param initial_program: program name. :type initial_program: str :param environment: environment server. :type environment: str Usage: >>> # Call the method: >>> self.open_url_coverage(url=self.config.url, initial_program=initial_program, environment=self.config.environment)

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)
parameter_url(restore_backup=False)

[Internal]

Internal method of set and restore parameters.

Parameters:

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

Usage:

>>> # Calling the method:
>>> self.parameter_url(restore_backup=False)
parameter_url_value(language, values={'en-us': '', 'es-es': '', 'pt-br': ''})

[Internal]

Internal method of AddParameters to filter the values.

Parameters:
  • language (str) – The language of config file.

  • values (dict[str, str]) – The values organized by language.

Usage:

>>> # Calling the method:
>>> self.parameter_url_value(language = self.config.language.lower(), values = {'pt-br': portuguese_value })
pop_dict_itens(dict_, element_id)

[Internal]

procedure_screen(is_procedure_install)

[Internal]

Internal method of SetProcedures.

Usage:

>>> # Calling the method:
>>> self.parameter_screen(restore_backup=False)
program_screen(initial_program='', environment='', coverage=False, poui=False)

[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")
reload_user_screen()

[Internal]

Refresh the page - retry load user_screen

remove_mask(string, valtype=None, element=None)

[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"
report_comparison(base_file='', current_file='')

Compare two reports files and if exists show the difference between then if exists.

Warning

Important to use BaseLine_Spool key in config.json to work appropriately. Baseline_Spool is the path of report spool in yout environment

Warning

Some words are changed to this pattern below:

‘Emissão: 01-01-2015’ ‘Emision: 01-01-2015’ ‘DT.Ref.: 01-01-2015’ ‘Fc.Ref.: 01-01-2015’ ‘Hora…: 00:00:00’ ‘Hora Término: 00:00:00’ ‘/’ to ‘@’

Only .xml

‘encoding=””’ ‘“DateTime”>2015-01-01T00:00:00’ ‘ss:Width=”100”’

Parameters:
  • base_file – Base file that reflects the expected. If doesn’t exist make a copy of auto and then rename to base

  • current_file – Current file recently impressed, this file is use to generate file_auto automatically.

>>> # File example:
>>> # acda080rbase.##r
>>> # acda080rauto.##r
>>> # Calling the method:
>>> self.oHelper.ReportComparison(base_file="acda080rbase.##r", current_file="acda080rauto.##r")
:return:
restart()

[Internal]

Restarts the Protheus Webapp and fills the initial screens.

Usage:

>>> # Calling the method:
>>> self.restart()
restart_browser()

[Internal]

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)
return_data(df, has_header, column)

[Internal]

return_grid_by_index(column_name)

[Internal]

return_header_index(column_name=None, headers=None)

[Internal]

return_soup_by_selenium(elements, term, selectors)
Parameters:
  • elements

  • term

Returns:

returns_printable_string(string)

Returns a string only is printable characters [Internal] :param string: string value :type string: str

scroll_grid_check_elements_change(xpath)

[Internal] Used to check PG_DOWN correct execute.

scroll_to_container(container, term)
Parameters:
  • container

  • term

Returns:

search_browse_column(search_column, search_elements, index=False)

[Internal]

Chooses the search key to be used during the search.

Parameters:
  • search_column (str) – The search Column 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("Filial*", search_elements)
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_browse_key_input_value(browse_input)

[Internal]

Get the search browse input value

search_element_position(field, position=1, input_field=True, direction=None)

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

search_for_errors(check_help=True)

[Internal] Searches for errors and alerts in the screen. Usage: >>> # Calling the method: >>> self.search_for_errors()

search_grid_by_text(grid, text, column_index)

[Internal] Searches for text in grid columns Returns the div containing the text

search_navigation_bar(container)

[Internal] Searches for navigation buttons into bs4 object.

Returns:

selenium object or None

Return type:

navigation selenium object

Usage: >>> # Calling the method: >>> self.search_navigation_bar(container)

search_text(selector, text)

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

Usage:

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

[Internal]

selected_row(grid_number=0)

[Internal]

Returns the selected row in the grid.

Parameters:

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

Usage:

>>> # Calling the method to return the selected row:
>>> oHelper.selected_row(grid_number = 0)
selenium_web_scrap(term, container, optional_term, second_term=None)

[Internal] Return selenium web element

send_action(action=None, element=None, value=None, right_click=False, click_type=None, wait_change=True)

Sends an action to element and compare it object state change.

Parameters:
  • action – selenium function as a reference like click, actionchains or send_keys.

  • element – selenium element as a reference

  • value – send keys value

  • right_click – True if you want a right click

  • click_type (int) – ClickType enum. 1-3 types- Default: None

Returns:

True if there was a change in the object

service_process_bat_file()

[Internal] This method creates a batfile in the root path to kill the process and its children.

set_grid_focus(grid_number=0)

[Internal]

set_log_info()

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

Usage:

>>> # Calling the method:
>>> self.set_log_info()
set_log_info_config()

[Internal]

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")
slm_click_last_item(sub_menu_child_label)

[Internal]

SetLateralMenu, this method retry click in the last sub item

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 (bool) – Try open standard search field send key F3 (no click).

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)
sub_string(line, file_extension)
Parameters:
  • line

  • file_extension

Returns:

supported_keys(key='')

[Internal]

switch_to_active_element()

[Internal] Call switch_to_active_element method

tmenupopupitem()
Returns:

treenode(tree_number=0)
Returns:

treenode bs4 object

treenode_selected(label_filtered, tree_number=0)

[Internal] Returns a tree node selected by label

try_click(element)

[Internal]

try_element_to_be_clickable(element)

Try excpected condition element_to_be_clickable by XPATH or ID

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)
update_password()

[Internal] Update the password in the Protheus password change request screen

user_screen(admin_user=False)

[Internal]

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

Usage:

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

[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()

[Internal]

Wait blocker disappear

wait_element(term, scrap_type=ScrapType.TEXT, presence=True, position=0, optional_term=None, main_container='.tmodaldialog,.ui-dialog,wa-dialog', check_error=True, twebview=False, second_term=None)

[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_is_blocked(parent_id)
Parameters:

parent_id

Returns:

wait_element_is_focused(element_selenium=None, time_out=5, step=0.1)

[ Internal ] Wait element Lose focus

wait_element_is_not_displayed(element_soup, timeout=5, step=0.3)

[Internal]

Wait element.is_displayed() return false :param element_soup: The element soup. :type element_soup: BeautifulSoup object. :param timeout: The maximum amount of time of wait. - Default: 5.0 :type timeout: float :param step: The amount of time each step should wait. - Default: 0.1 :type step: float

Usage:

>>> # Calling the method:
>>> self.wait_element_is_not_displayed(soup_element, 10, 0.5)
wait_element_is_not_focused(element_selenium=None, time_out=5, step=0.1)

[ Internal ] Wait element Lose focus

wait_element_timeout(term, scrap_type=ScrapType.TEXT, timeout=5.0, step=0.1, presence=True, position=0, optional_term=None, main_container='.tmodaldialog,.ui-dialog, wa-dialog, body', check_error=True, twebview=False)

[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_gridTree(n_lines, timeout=None)

[Internal] Wait until the GridTree line count increases or decreases.

wait_selected_row(grid_number=0, column_index=0, text='default-text', time_out=5)

[Internal]

This method expects the selected line to be the line with the text value entered.

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

  • column_index (int) – The column index

  • text (string) – The value of column to be matched

Usage:

>>> # Calling the method to wait the selected row:
>>> oHelper.wait_selected_row(grid_number = 0, column_index = 0, text= "value" )
wait_smart_erp_environment()

[Internal]

wait_until_to(expected_condition='element_to_be_clickable', element=None, locator=None, timeout=False)

[Internal]

This method is responsible for encapsulating “wait.until”.

web_scrap(term, scrap_type=ScrapType.TEXT, optional_term=None, label=False, main_container=None, check_error=True, check_help=True, input_field=True, direction=None, position=1, twebview=False, second_term=None)

[Internal]

Returns a BeautifulSoup or selenium 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

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

Returns:

List of BeautifulSoup4 or Selenium elements based on search parameters.

Return type:

List of BeautifulSoup4 or Selenium 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")