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.")
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")
AssertFalse(expected=False, scritp_message='')

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(expected=True, scritp_message='')

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 ")
ChangeUser(user, password, initial_program='', date='', group='99', branch='01')

Change the user.

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=False)

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. If the field is a colored status (without name) you must set it empty ex: CheckResult(field=””, user_value=”Red”, grid=True, position=1)

  • 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 (bool) – False if the desired field is not an input type .

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

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

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

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

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” - 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, 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)
ClickByLocator(selector='', locator='', right_click=False)

Note

Necessary import “By” class in the script: from tir.technologies.core.base import By

Note

For more information check this out: https://selenium-python.readthedocs.io/locating-elements.html

Warning

Use only in cases where it is not possible to use a label or name attribute. Any interface change can directly impact the script. Evaluate the possibility of changing the interface before using these methods in the script.

Parameters:
  • selector (str) – The type of selector to use (e.g., ‘css’, ‘xpath’, ‘id’).

  • locator (str) – The locator expression to identify the element. (e.g., By.CSS_SELECTOR, By.ID)

  • right_click (bool) – Perform a right-click action if True (default is False).

Usage:

>>> # Calling the method:
>>> oHelper.ClickByLocator(selector='COMP7536', locator=By.ID)
:return: None
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(item, position=1)

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=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.

Parameters:
  • icon_text (str) – The tooltip 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)

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")
ClickMenuFunctional(menu_name, menu_option)

Click on the functional menu. :param menu_option: Item to be clicked. :type menu_option: src

Usage:

>>> # Call the method:
>>> oHelper.ClickMenuFunctional("label","button") 
ClickMenuPopUpItem(text, right_click=False, 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=1)

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)
>>> # tree_number example:
>>> oHelper.ClickTree("element 1 > element 2 > element 3", position=2)
CurrentWorkDirectory()
Returns:

Returns the current working directory

F3(field, name_attr=False, send_key=False)

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 (bool) – True: try open standard search field send key F3.

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()
GetConfigValue(json_key)
Parameters:

json_key (str) – Json Key in config.json

Returns:

Json Key item in config.json

GetGrid(grid_number=1, grid_element=None)

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” Default:If None return all webapp classes.

Type:

int

Type:

str

Returns:

Grid BeautifulSoup object

Return type:

BeautifulSoup object

Class css selector sintaxe: .class .intro Selects all elements with class=”intro”

Usage:

>>> # Calling the method:
>>> my_grid = self.get_grid()
>>> my_grid = self.get_grid(grid_element='.dict-msbrgetdbase')
GetLineNumber(values, columns=[], grid_number=0)
Parameters:
  • values – values composition expected in respective columns

  • columns – reference columns used to get line

  • grid_number

Returns:

GetRelease()

Get the current release from Protheus.

Returns:

The current release from Protheus.

Type:

str

Usage:

>>> # Calling the method:
>>> oHelper.GetRelease()
>>> # Conditional with method:
>>> # Situation: Have a input that only appears in release greater than or equal to 12.1.027
>>> if self.oHelper.GetRelease() >= '12.1.027':
>>>     self.oHelper.SetValue('AK1_CODIGO', 'codigo_CT001')
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. If the column is a colored status, you must set the field as “” , ex: GetValue(“”, grid=True, position= 1)

  • 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, treepath, 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)
IfExists(string='', timeout=5)

Returns True if element exists in timeout or return False if not exist.

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

  • timeout (str) – Timeout that wait before return.

Usage:

>>> # Calling the method:
>>> exist = oHelper.IfExists("Aviso", timeout=10)
>>> if oHelper.IfExists("Aviso", timeout=10):
>>>     print('Found!')
InputByLocator(selector='', locator='', value='')

Note

Necessary import “By” class in the script: from tir.technologies.core.base import By

Note

For more information check this out: https://selenium-python.readthedocs.io/locating-elements.html

Warning

Use only in cases where it is not possible to use a label or name attribute. Any interface change can directly impact the script. Evaluate the possibility of changing the interface before using these methods in the script.

Parameters:
  • selector (str) – The type of selector to use (e.g., ‘css’, ‘xpath’, ‘id’).

  • locator (str) – The locator expression to identify the element. (e.g., By.CSS_SELECTOR, By.ID)

  • value (str) – The value to be used (e.g., for input or interaction).

Usage:

>>> # Calling the method:
>>> oHelper.InputByLocator(selector='COMP7526', locator=By.ID, value='teste')
:return: None
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.

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")
OpenCSV(csv_file='', delimiter=';', column=None, header=None, filter_column=None, 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.

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

  • filter_data (bool) – If you want filter a value by column, this parameter need to be a True value

>>> # Call the method:
>>> file_csv = self.oHelper.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')
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")
ProgramScreen(initial_program='')

Fills the first screen of Protheus with the first program to run. :param initial_program: The initial program to load :type initial_program: str

Usage:

>>> # Calling the method:
>>> self.oHelper.ProgramScreen("SIGAADV")
QueryExecute(query, database_driver='', dbq_oracle_server='', database_server='', database_port=1521, database_name='', database_user='', database_password='')

Return a dictionary if the query statement is a SELECT otherwise print a number of row affected in case of INSERT|UPDATE|DELETE statement.

Note

Default Database information is in config.json another way is possible put this in the QueryExecute method parameters: Parameters: “DBDriver”: “”, “DBServer”: “”, “DBName”: “”, “DBUser”: “”, “DBPassword”: “”

Note

Must be used an ANSI default SQL statement.

Note

dbq_oracle_server parameter is necessary only for Oracle connection.

Parameters:
  • query (str) – ANSI SQL estatement query

  • database_driver (str) – ODBC Driver database name

  • dbq_oracle_server (str) – Only for Oracle: DBQ format:Host:Port/oracle instance

  • database_server (str) – Database Server Name

  • database_port (int) – Database port default port=1521

  • database_name (str) – Database Name

  • database_user (str) – User Database Name

  • database_password (str) – Database password

Usage:

>>> # Call the method:
>>> self.oHelper.QueryExecute("SELECT * FROM SA1T10")
>>> self.oHelper.QueryExecute("SELECT * FROM SA1T10", database_driver="DRIVER_ODBC_NAME", database_server="SERVER_NAME", database_name="DATABASE_NAME", database_user="sa", database_password="123456")
>>> # Oracle Example:
>>> self.oHelper.QueryExecute("SELECT * FROM SA1T10", database_driver="Oracle in OraClient19Home1", dbq_oracle_server="Host:Port/oracle instance", database_server="SERVER_NAME", database_name="DATABASE_NAME", database_user="sa", database_password="123456")
ReplaceSlash(path)
Parameters:

path (str) – Path that will be normalized depending on operating system(Windows, Linux).

Returns:

Returns the path with the correct slash according to the OS

ReportComparison(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 (str) – Base file that reflects the expected. If doesn’t exist make a copy of auto and then rename to base

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

Usage:

>>> # File example:
>>> # acda080rbase.##r
>>> # acda080rauto.##r
>>> # Calling the method:
>>> self.oHelper.ReportComparison(base_file="acda080rbase.##r", current_file="acda080rauto.##r")
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, 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

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

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)
>>> #------------------------------------------------------------------------
>>> # To search using the first search box and a chosen column:
>>> oHelper.SearchBrowse("D MG 001", column="Nome")
>>> #------------------------------------------------------------------------
>>> #------------------------------------------------------------------------
>>> # To search using the first search box and a chosen columns:
>>> oHelper.SearchBrowse("D MG 001", column="Nome, Filial*, ColumnX, AnotherColumnY")
>>> #------------------------------------------------------------------------
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

> ⚠️ Warning: > If there are a sequence of similar buttons. Example: self.oHelper.SetButton(“Salvar”) self.oHelper.SetButton(“Salvar”) We recomend insert some wait of elements method between them, like WaitShow, WaitHide… etc. This way you ensure the correct element be selected in correct screen.

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")
SetCalendar(day='', month='', year='')

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

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

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)
>>> #--------------------------------------
>>> # Calling the method when you expected new window or text appears 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(menuitens, 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.

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)
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, check_value=None, grid_memo_field=False, range_multiplier=None, direction=None, duplicate_fields=[])

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

  • check_value – Boolean ignore input check - Default: True

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

  • 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 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()
>>> #-----------------------------------------
>>> # Calling method to input value on a field that is a grid (2) *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='')

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 ")
SetupTSS(initial_program='', environment='')

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")
Start()

Opens the browser maximized and goes to defined URL.

Usage:

>>> # Calling the method:
>>> oHelper.Start()
StartDB()
Returns:

connection object

Usage:

>>> # Call the method:
>>> self.oHelper.StartDB()
StartSchedule()

Access de Schedule settings and Start all itens

StopDB(connection)
Parameters:

connection – connection object

Usage:

>>> # Call the method:
>>> self.oHelper.StopDB(connection)
StopSchedule()

Access de Schedule settings and Stop all itens

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

Search string that was sent and wait hide the elements.

Parameters:
  • itens – String that will hold the wait.

  • timeout (str) – Timeout that wait before return.

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

Search string that was sent and wait show the elements.

Parameters:
  • itens – String that will hold the wait.

  • timeout (str) – Timeout that wait before return.

Usage:

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