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:
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: str = '', group: str = '', branch: str = '', module: str = '') None
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:
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, radio_input, columns=None, values=None, match_all=False, icon_class=None)
Clicks on the Table of POUI component. https://po-ui.io/documentation/po-table
Supports both legacy and new syntax:
Legacy syntax (backward compatible): >>> oHelper.ClickTable(“Code”, “”, “000001”, “”, click_cell=”Edit”) >>> oHelper.ClickTable(“Code”, “Name”, “000001”, “John”, click_cell=”Edit”)
New syntax (recommended):
>>> oHelper.ClickTable(columns='Code', values='000001', click_cell='Edit') >>> oHelper.ClickTable(columns=['Code', 'Name'], values=['000001', 'John'], click_cell='Edit')
- Parameters:
first_column (str) – [LEGACY] First column name - Default: “”
second_column (str) – [LEGACY] Second column name - Default: “”
first_content (str) – [LEGACY] First column content - Default: “”
second_content (str) – [LEGACY] Second column content - Default: “”
table_number (int) – Grid position number when multiple grids exist - Default: 1
itens (bool) – [LEGACY] Click all items matching criteria - Default: False
click_cell (str) – Column name to click - Default: “”
checkbox (bool) – Click checkbox - Default: False
radio_input (bool) – Click radio button - Default: False
columns (list or str) – [NEW] List of column names or comma-separated string - Default: None
values (list or str) – [NEW] List of values or comma-separated string - Default: None
match_all (bool) – [NEW] If True, click in all matching rows - Default: False
Usage:
>>> # Legacy calls (still supported): >>> oHelper.ClickTable("Branch", "", "D MG 01", "", click_cell="Edit") >>> oHelper.ClickTable("Code", "Name", "000001", "John") >>> oHelper.ClickTable("Code", "", "000001", "", itens=True)
>>> # New calls (recommended): >>> oHelper.ClickTable(columns='Branch', values='D MG 01', click_cell='Edit') >>> oHelper.ClickTable(columns=['Code', 'Name'], values=['000001', 'John']) >>> oHelper.ClickTable(columns='Status', values=True, match_all=True, checkbox=True) >>> # Click icon in row: >>> oHelper.ClickTable(columns='Code', values='000001', icon_class='arrow-up-right') >>> oHelper.ClickTable(columns='Code', values='000001', icon_class='ph-arrow-up-right')
- Returns:
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:
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, exec_enter_tab: bool = True)
Filling input component of POUI https://po-ui.io/documentation/po-input
- Parameters:
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
- Program(program_name: str = '', program_desc: str = '')
[Internal]
Method that sets the program in the initial menu search field on New Home.
- Parameters:
program (str) – The program name
Usage:
>>> # Calling the method: >>> self.set_program_new_home("MATA020")
- SearchBrowse(term='', key=None, identifier=None, index=False, column=None, filters=None) None
Routes to FilterBrowse when filters parameter is provided. Maintains interface compatibility with WebappInternal.SearchBrowse.
- Parameters:
filters (dict or list) – Filters to apply on THF Browse. If provided, routes to FilterBrowse.
Note
Parameters key, identifier, index and column are not applicable in POUI context. They exist only for interface compatibility with WebappInternal.SearchBrowse.
- SetButton(button, sub_item='', position=1, check_error=True)
Legacy webapp adaptation for POUI. Wraps click_button with specific button mapping rules.
- 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:
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_layers(term)
[Internal]
- check_mot_exec()
Check MotExec key content
- Returns:
- checkbox_is_checked(checkbox_element)
Verifica se o checkbox está marcado em componentes POUI ou Kendo Grid.
- Parameters:
checkbox_element (bs4.element.Tag) – Elemento BeautifulSoup4 do checkbox
- Returns:
True se o checkbox estiver marcado, False caso contrário
- Return type:
Usage:
>>> # Calling the method: >>> is_checked = self.checkbox_is_checked(checkbox_element)
- 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:
- Returns:
The count of elements matching the children_selector inside of element_selector.
- Return type:
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=1, selector='po-button, po-dropdown', container=False)
- 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_checkbox(label)
Click on the POUI Checkbox. https://po-ui.io/documentation/po-checkbox
- Parameters:
label (str)
Usage:
>>> # Call the method: >>> oHelper.ClickCheckBox(label="CheckBox label")
- click_combo(field, value='', position=1, second_value='')
Select a value for list combo inputs.
- Parameters:
field – label of field
:type : str :param value: value to input on field :type : str :param position: :type : int :param second_value: value below the principal value (after the “:”) :type : str :return:
- click_icon(label, class_name, position)
Click on the POUI Icon by label, class_name or both. https://po-ui.io/guides/icons
- Parameters:
- 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_look_up(label=None, search_value=None)
Use to click and search value in Lookup components
https://po-ui.io/documentation/po-lookup :param label: field from lookup input :type: str :param search_value: Value to input in search field :type: str :return:
- click_po_list_box(value='', second_value='', program_call=False) None
- Parameters:
value – Value to select on po-list-box
:type str :param second_value: value below the principal value (after the “:”) :type : str :return:
- 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_select(field, value, position)
- 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
- click_switch(label='', value=True, position=1)
Click on POUI Switch component https://po-ui.io/documentation/po-switch
- close_coin_screen()
[Internal]
Closes the coin screen.
Usage:
>>> # Calling the method: >>> self.close_coin_screen()
- 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()
- 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)
- data_frame(object)
Return a DataFrame from a Beautiful Soup Table
- Parameters:
object – BeautifulSoup4 Table
- Returns:
Pandas dataframe
- 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, use_current_container=False)
[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:
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, twebview=True)
[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()
- execute_js_selector(term, objects, get_all=True, shadow_root=True)
Execute a javascript selector in a selenium object and return the element or elements found :param term: Css selector :param objects: Selenium object :param get_all: True if you want all elements found or False if you want only the first element found :param shadow_root: True if the element is in a shadow root :return: Selenium object or list of selenium objects
- filling_branch(shadow_root=None, container=None)
[Internal]
- filling_date(shadow_root=None, container=None)
[Internal]
- filling_environment(shadow_root=None, container=None)
[Internal]
- filling_group(shadow_root=None, container=None, group_value='')
[Internal]
- 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, position, twebview=False, label_selector='')
[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)
- find_po_item_list(po_item_list, param_label, param_value)
This method is used to filter the po-item-list elements based on the label and value match.
- Parameters:
list_elements (list) – list of BeautifulSoup po-item-list elements
label_text
value_text
attr – attribute to be checked in the po-item-list
- Returns:
Filtered BeautifulSoup element or None if not found
- get_closest_element(ref_element, element_list, direction=None, input_field=True, twebview=True)
Find the closest element by term from a reference element using euclidean distance (location x,y).
- Parameters:
ref_element (bs4.element.Tag) – The reference element to calculate the distance from.
direction – The direction to filter the elements. Options are ‘right’, ‘down
[Internal] Usage: >>> # Calling the method >>> self.get_closer_element_by_location(label_pos, elements_list, direction=None)
- get_component_by_label(label, selector, position)
Get BS object by label. :param label: :param selector: :param position: :return:
- get_config_value(json_key)
- Parameters:
json_key (str) – Json Key in config.json
- Returns:
Json Key item in config.json
- get_current_container()
[Internal]
An internal method designed to get the current container. Returns the BeautifulSoup object that represents this container or NONE if nothing is found.
- Returns:
The container object
- Return type:
BeautifulSoup object
Usage:
>>> # Calling the method: >>> container = self.get_current_container()
- get_distance(label_pos, element_pos)
[internal]
- get_distance_x(x_label, x_element)
[Internal]
- get_distance_y(y_label, y_element)
[Internal]
- get_dropdown_state(dropdown_element)
Get the current state of a POUI Dropdown component https://po-ui.io/documentation/po-dropdown
- Parameters:
dropdown_element (BeautifulSoup object) – BeautifulSoup object representing the dropdown component
- Returns:
Current state of the dropdown (open/closed)
- Return type:
Usage:
>>> # Calling the method: >>> dropdown_state = self.get_dropdown_state(dropdown_element)
- 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:
- 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_headers_from_grids(grids, column_name='', position=0)
[Internal]
Returns a Dict with the headers and their indexes of each grid in grids parameter.
- Parameters:
grids (List of BeautifulSoup objects) – The grids to extract the headers.
- Returns:
List of Dictionaries with each header value and index.
- Return type:
List of Dict
Usage:
>>> # Calling the method: >>> headers = self.get_headers_from_grids(grids)
- get_iframe_size()
[Internal] Gets the size of the current iframe when no container ID is available.
- Returns:
Dictionary with width and height of the iframe
- Return type:
- get_language()
[Internal]
Gets the current language of the html.
- Returns:
The current language of the html.
- Return type:
Usage:
>>> # Calling the method: >>> language = self.get_language()
- get_position_from_bs_element(element, twebview=True)
[Internal]
- get_program_name()
[Internal]
- get_release()
Gets the current release of the Protheus.
- Returns:
The current release of the Protheus.
- Type:
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_soup_select(selector)
Get a soup select object.
- Parameters:
selector – Css selector
- Returns:
Return a soup select object
- get_switch_value(switch_component)
Get the current value of a POUI Switch component https://po-ui.io/documentation/po-switch
- Parameters:
switch_component (BeautifulSoup object) – BeautifulSoup object representing the switch component
- Returns:
Current value of the switch (True/False)
- Return type:
Usage:
>>> # Calling the method: >>> switch_value = self.get_switch_value(switch_component)
- 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:
Usage:
>>> # Calling the method: >>> current_value = self.get_web_value(selenium_field_element)
- is_active_element(element)
[Internal]
Return true if an element is active status
- Parameters:
element (Selenium object) – Element to analyse
- Returns:
A list containing a BeautifulSoup object next to the label
- Return type:
List of BeautifulSoup objects
- log_error(message, new_log_line=True, skip_restart=False, restart_counter_param=None)
[Internal]
Finishes execution of test case with an error and creates the log information for that test.
- Parameters:
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:
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_input_combo(po_combo)
- Parameters:
po_combo – po-combo object
- Type:
Bs4 object
- Returns:
- 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]
- poui_click(element, click_type=1)
POUI Click method :param element: :param click_type: ClickType enum. 1-3 types- Default: 1 :type click_type: int :return:
- 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:
Usage:
>>> # Calling the method >>> self.program_screen("SIGAADV", "MYENVIRONMENT")
- radio_is_active(radio)
Check if radio is active
- Parameters:
radio – BeautifulSoup4
- Returns:
Boolean
- 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, position)
- 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, input_selector='')
[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)
- send_action(action=None, element=None, value=None, right_click=False, click_type=None, wait_change=True, twebview=None)
Sends an action to element and compare it object state change.
- Parameters:
action – selenium function as a reference like click, actionchains or send_keys.
element – selenium element as a reference
value – send keys value
right_click – True if you want a right click
click_type (int) – ClickType enum. 1-3 types- Default: None
- Returns:
True if there was a change in the object
- service_process_bat_file()
[Internal] This method creates a batfile in the root path to kill the process and its children.
- set_log_info()
[Internal] Fills the log information needed by opening the About page.
Usage:
>>> # Calling the method: >>> self.set_log_info()
- set_log_info_config()
[Internal]
- string_to_json(string)
Convert a string to a json object
- Parameters:
string (str) – String to be converted
- Returns:
json object
- sub_string(line, file_extension)
- Parameters:
line
file_extension
- Returns:
- switch_to_active_element()
[Internal] Call switch_to_active_element method
- toggle_radio(po_radio, active=True)
Set input Radio from a tr Tag element
- Parameters:
po_radio – BeautifulSoup4
- Returns:
- try_click(element)
[Internal]
- try_send_keys(element_function, key, try_counter=1)
[Internal]
Tries to send value to element using different techniques. Meant to be used inside of a loop.
- Parameters:
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, twebview=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, twebview=False, use_current_container=False)
[Internal]
Waits until the desired element is located on the screen or until the timeout is met.
- Parameters:
term (str) – The first search term. A text or a selector.
scrap_type (enum.ScrapType.) – The type of webscraping. - Default: enum.ScrapType.TEXT
timeout (float) – The maximum amount of time of wait. - Default: 5.0
timeout – The amount of time each step should wait. - Default: 0.1
presence (bool) – If the element should exist or not in the screen. - Default: False
position (int) – If the element should exist at a specific position. e.g. The fourth button. - Default: 0
optional_term (str) – The second search term. A selector used in MIXED webscraping. - Default: None
main_container (str) – The selector of a container element that has all other elements. - Default: None
Usage:
>>> # Calling the method: >>> self.wait_element_timeout(term=button, scrap_type=enum.ScrapType.MIXED, optional_term="button", timeout=10, step=0.1)
- wait_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=None)
[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")