Poui Internal

class tir.technologies.poui_internal.PouiInternal(config_path='', autostart=True)

Internal implementation of POUI class.

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

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 = PouiInternal(config_path, autostart)
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" )
>>> #------------------------------------------------------------------------
CheckResult(field, user_value, po_component, position)

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.

  • po_component (str) – POUI component name that you want to check content on screen

Usage:

>>> # Calling method to check a value of a field:
>>> oHelper.CheckResult("Código", "000001", 'po-input')
ClickMenu(menu_item)

Clicks on the menuitem of POUI component. https://po-ui.io/documentation/po-menu?view=doc

Parameters:

menu_item – The Menu item name

Usage:

>>> # Call the method:
>>> oHelper.ClickMenu("Contracts")
ClickTable(first_column, second_column, first_content, second_content, table_number, itens, click_cell, checkbox)

Clicks on the Table of POUI component. https://po-ui.io/documentation/po-table

Parameters:
  • first_column (str) – Column name to be used as reference.

  • second_column (str) – Column name to be used as reference.

  • first_content (str) – Content of the column to be searched.

  • second_content (str) – Content of the column to be searched.

  • table_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.

  • click_cell (str) – Content to click based on a column position to close the axis

  • checkbox (bool) – If you want to click on the checkbox component in the table

>>> # Call the method:
>>> oHelper.ClickTable(first_column='Código', first_content='000003', click_cell='Editar')
:return: None
ClickWidget(title, action, position)

Clicks on the Widget or Widget action of POUI component. https://po-ui.io/documentation/po-widget

Parameters:
  • tittle – Widget text title that you want to click.

  • action – The name of action to be clicked

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

Usage:

>>> # Call the method:
>>> oHelper.ClickWidget(title='LEad Time SC x PC', action='Detalhes', position=1)
:return:
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, grid_memo_field=False)

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

Usage:

>>> # Calling the method:
>>> current_value = oHelper.GetValue("A1_COD")
InputValue(field, value, position)

Filling input component of POUI https://po-ui.io/documentation/po-input

Parameters:
  • field (str) – Input text title that you want to fill

  • value (str) – Value that fill in input

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

Usage:

>>> # Call the method:
>>> oHelper.InputValue('Name', 'Test')
:return: None
LengthGridLines(grid)

Returns the length of the grid. :return:

LogOff()

Logs out of the Protheus Webapp.

Usage:

>>> # Calling the method.
>>> oHelper.LogOff()
POSearch(content, placeholder)

Fill the POUI Search component. https://po-ui.io/documentation/po-page-dynamic-search

Parameters:

content (str) – Content to be Search.

Usage:

>>> # Call the method:
>>> oHelper.POSearch(content='Content to be Search')
:return: None
POTabs(label)

Clicks on a Label in po-tab. https://po-ui.io/documentation/po-tabs

Parameters:

label (str) – The tab label name

>>> # Call the method:
>>> oHelper.POTabs(label='Test')
:return: None
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)

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 (bool) – Boolean if search by Name attribute must be forced. - Default: False

  • 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()
TearDown()

Closes the webdriver and ends the test case.

Usage:

>>> #Calling the method
>>> self.TearDown()
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")
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)
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_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_mot_exec()

Check MotExec key content

Returns:

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")
click_avatar(position)

Click on the POUI Profile Avatar icon. https://po-ui.io/guides/Avatar

Parameters:

position (int) –

  • Default: 1

Usage:

>>> # Call the method:
>>> oHelper.ClickAvatar(position=1)
>>> oHelper.ClickAvatar()
click_button(button, position, selector, container)
Parameters:
  • field – Button to be clicked.

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

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_icon(label, class_name, position)

Click on the POUI Icon by label, class_name or both. https://po-ui.io/guides/icons

Parameters:
  • label (str) – The tooltip name for icon

  • class_name (str) – The POUI class name for icon

  • position (int)

Returns:

None

Usage:

>>> # Call the method:
>>> oHelper.ClickIcon(label='Delete')
>>> oHelper.ClickIcon(class_name='po-icon po-icon-delete')
>>> oHelper.ClickIcon(label='Delete', class_name='po-icon po-icon-delete')
click_popup(label)

Click on the POUI Profile Avatar icon. https://po-ui.io/documentation/po-popup

Parameters:

label (str)

Usage:

>>> # Call the method:
>>> oHelper.ClickPopup(label="Popup Item")
>>> oHelper.ClickPopup()
click_poui_component(field, value, position, selector, container)
Parameters:
  • field – Combo text title that you want to click.

  • value – Value that you want to select in Combo.

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

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

[Internal]

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)
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='.body', check_error=True, twebview=True)

[Internal]

Returns a boolean if element exists on the screen.

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

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

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

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

Returns:

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

Return type:

bool

Usage:

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

[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()
filter_by_direction(xy_label, width_safe, height_safe, position_list, direction)

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

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

Usage:

>>> #Calling the method
>>> elements = self.filter_label_element(label_text, container)
find_label_element(label_text, container=None, position=1, 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)
get_config_value(json_key)
Parameters:

json_key (str) – Json Key in config.json

Returns:

Json Key item in config.json

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_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_content(grid_number, grid_element)
Parameters:
  • grid_number

  • grid_element

Returns:

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_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:
>>> oHelper.get_release()
>>> # Conditional with method:
>>> # Situation: Have a input that only appears in release greater than or equal to 12.1.023
>>> if self.oHelper.get_release() >= '12.1.023':
>>>     self.oHelper.SetValue('AK1_CODIGO', 'codigoCT001')
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_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)
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")
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)

po_loading(selector)
Returns:

pop_dict_itens(dict_, element_id)

[Internal]

program_screen(initial_program='', environment='', coverage=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

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

[Internal]

return_icon_class(class_name, elements)
Parameters:
  • class_name (str) – The POUI class name for icon

  • elements (object) – bs4 element

Returns:

filtered bs4 object

return_input_element(field=None, position=1, term=None)

[Internal] Returns input element based on field

return_main_element(field, position, selector, container)
Returns:

returns_printable_string(string)

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

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_text(selector, text)

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

Usage:

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

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

set_log_info()

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

Usage:

>>> # Calling the method:
>>> self.set_log_info()
sub_string(line, file_extension)
Parameters:
  • line

  • file_extension

Returns:

switch_to_active_element()

[Internal] Call switch_to_active_element method

try_click(element)

[Internal]

try_send_keys(element_function, key, try_counter=0)

[Internal]

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

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

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

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

Usage:

>>> # Calling the method:
>>> self.try_send_keys(selenium_input, user_value, try_counter)
user_screen(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()
wait_element(term, scrap_type=ScrapType.CSS_SELECTOR, presence=True, position=0, optional_term=None, main_container='body', check_error=True)

[Internal]

Waits until the desired element is located on the screen.

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

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

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

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

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

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

Usage:

>>> # Calling the method:
>>> self.wait_element(term=".ui-button.ui-dialog-titlebar-close[title='Close']", scrap_type=enum.ScrapType.CSS_SELECTOR)
wait_element_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, body', check_error=True)

[Internal]

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

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

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

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

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

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

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

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

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

Usage:

>>> # Calling the method:
>>> self.wait_element_timeout(term=button, scrap_type=enum.ScrapType.MIXED, optional_term="button", timeout=10, step=0.1)
wait_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)

[Internal]

Returns a BeautifulSoup object list based on the search parameters.

Does not support ScrapType.XPATH as scrap_type parameter value.

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

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

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

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

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

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

Returns:

List of BeautifulSoup4 elements based on search parameters.

Return type:

List of BeautifulSoup4 objects

Usage:

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