Webapp

class tir.main.Webapp(config_path='', autostart=True)

Instantiates the Webapp automated interface testing class.

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

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.")
AssertFalse()

Defines that the test case expects a False response to pass

Usage:

>>> #Instantiating the class
>>> inst.oHelper = Webapp()
>>> #Calling the method
>>> inst.oHelper.AssertFalse()
AssertTrue()

Defines that the test case expects a True response to pass

Usage:

>>> #Instantiating the class
>>> inst.oHelper = Webapp()
>>> #Calling the method
>>> inst.oHelper.AssertTrue()
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” - closes element.

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

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

Usage:

>>> # Calling the method.
>>> oHelper.CheckView("Processing")
ClickBox(fields, contents_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) – Grid number of which grid should be used when there are multiple grids on the same screen. - Default: 1

  • ignore_current (bool) – Boolean to ignore the get_current_filtered on loop case of box click. - Default: False

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) – index label box on interface

Usage:

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

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=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(text, right_click=False)

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 “>” .

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

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)
F3(field, name_attr=False, send_key=False)

This method is similar to ClickIcon 1.Clicks on the Selenium element.

[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) – True: searchs element by name

  • send_key – True: try open standard search field send key F3

:type bool

Usage:

>>> # To search using a label name:
>>> oHelper.F3("Cód")
>>> #------------------------------------------------------------------------
>>> # To search using the name of input:
>>> oHelper.F3(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)
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. .. note:

.Do not use this method in any routine. Use on home screen

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()
Screenshot(filename)

Takes a screenshot and saves on the screenshot folder defined in config.

Parameters

filename – The name of the screenshot file.

Type

str

Usage:

>>> # Calling the method:
>>> oHelper.Screenshot(filename="myscreenshot")
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")
>>> oHelper.SearchBrowse("D MG 001", identifier="Products")
>>> #------------------------------------------------------------------------
>>> # To search using an index instead of name for the search key:
>>> oHelper.SearchBrowse("D MG 001", key=2, index=True)
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")
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=False, row_number=1)

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")
SetKey(key, grid=False, grid_number=1, additional_key='')

Press the desired key on the keyboard on the focused 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

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

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.

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()
SetTIRConfig(config_name, value)

Changes a value of a TIR internal config during runtime.

This could be useful for TestCases that must use a different set of configs than the ones defined at config.json

Available configs:

  • Url

  • Environment

  • User

  • Password

  • Language

  • DebugLog

  • TimeOut

  • InitialProgram

  • Routine

  • Date

  • Group

  • Branch

  • Module

Parameters
  • config_name (str) – The config to be changed.

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

Usage:

>>> # Calling the method:
>>> oHelper.SetTIRConfig(config_name="date", value="30/10/2018")
SetTabEDAPP(table_name)

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 don’t use position parameter with grid parameter True.

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

  • value (str) – 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

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

Usage:

>>> # Calling method to input value on a field:
>>> oHelper.SetValue("A1_COD", "000001")
>>> #-----------------------------------------
>>> # Calling method to input value on a field using by label name:
>>> oHelper.SetValue("Codigo", "000001")
>>> #-----------------------------------------
>>> # Calling method to input value on a field using by an existing label name:
>>> oHelper.SetValue(field = "Codigo", value = "000002", position = 2)
>>> #-----------------------------------------
>>> # 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='')

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)

Usage:

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

Opens the browser maximized and goes to defined URL.

Usage:

>>> # Calling the method:
>>> oHelper.Start()
TearDown()

Closes the webdriver and ends the test case.

Usage:

>>> #Calling the method
>>> inst.oHelper.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)

Search string that was sent and wait hide the elements.

Parameters

itens – String that will hold the wait.

Usage:

>>> # Calling the method:
>>> oHelper.WaitHide("Processing")
WaitProcessing(string)

Uses WaitShow and WaitHide to Wait a Processing screen

Parameters

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

Usage:

>>> # Calling the method:
>>> oHelper.WaitProcessing("Processing")
WaitShow(string)

Search string that was sent and wait show the elements.

Parameters

itens – String that will hold the wait.

Usage:

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