Skip to content

Commit

Permalink
Merge pull request #431 from totvs/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Wilson08 authored Oct 26, 2020
2 parents 8a2c894 + 67ef824 commit 516965a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion scripts/install_package.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ taskkill /f /im chromedriver.exe
echo -------------------------
echo Installing project...
echo -------------------------
pip install -U dist/tir_framework-1.17.21.tar.gz
pip install -U dist/tir_framework-1.17.23.tar.gz
pause >nul | set/p = Press any key to exit ...
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
project_urls={
'Script Samples': 'https://github.com/totvs/tir-script-samples'
},
version='1.17.21',
version='1.17.23',
license='MIT',
keywords='test automation selenium tir totvs protheus framework',
classifiers=[
Expand Down
30 changes: 22 additions & 8 deletions tir/technologies/webapp_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1338,15 +1338,15 @@ def wait_blocker(self):
Wait blocker disappear
"""
blocker_container = None
blocker = None

print("Waiting blocker to continue...")
soup = None
result = True
endtime = time.time() + 300

while(time.time() < endtime and result):
blocker_container = None
blocker = None
soup = self.get_current_DOM()
blocker_container = self.blocker_containers(soup)
if blocker_container:
Expand Down Expand Up @@ -1418,6 +1418,7 @@ def search_element_position(self, field, position=1):
endtime = (time.time() + self.config.time_out)
label = None
position -= 1
elem = []

try:
while( time.time() < endtime and not label ):
Expand Down Expand Up @@ -1448,9 +1449,9 @@ def search_element_position(self, field, position=1):
distance = list(map(lambda x:(x[0], self.get_distance(xy_label,x[1])), position_list))
elem = min(distance, key = lambda x: x[1])
elem = list_in_range[elem[0]]
if not elem:
self.log_error("Element wasn't found.")

if not elem:
self.log_error(f"Label '{field}' wasn't found")
return elem

except AssertionError as error:
Expand Down Expand Up @@ -2406,6 +2407,7 @@ def SetLateralMenu(self, menu_itens, save_input=True):
count = 0
try:
for menuitem in menu_itens:
self.wait_blocker()
self.wait_until_to(expected_condition="element_to_be_clickable", element = ".tmenu", locator=By.CSS_SELECTOR )
self.wait_until_to(expected_condition="presence_of_all_elements_located", element = ".tmenu .tmenuitem", locator = By.CSS_SELECTOR )
menuitem_presence = self.wait_element_timeout(term=menuitem, scrap_type=enum.ScrapType.MIXED, timeout = self.config.time_out, optional_term=".tmenuitem", main_container="body")
Expand Down Expand Up @@ -3392,7 +3394,7 @@ def SetKey(self, key, grid=False, grid_number=1, additional_key="", wait_show =
if key not in hotkey and self.supported_keys(key):
if grid:
if key != "DOWN":
self.LoadGrid( wait_enable = False )
self.LoadGrid()
self.send_action(action=ActionChains(self.driver).key_down(self.supported_keys(key)).perform)
elif tries > 0:
ActionChains(self.driver).key_down(self.supported_keys(key)).perform()
Expand Down Expand Up @@ -3523,6 +3525,18 @@ def SetFocus(self, field, grid_cell, row_number):

label = False if re.match(r"\w+(_)", field) else True

if label:
container = self.get_current_container()
labels = container.select('label')

label_text_filtered = re.sub(r"[:;*?]", "", field)
label_filtered = next(iter(list(filter(
lambda x: re.sub(r"[:;*?]", "", x.text) == label_text_filtered, labels))), None)

if label_filtered and not self.element_is_displayed(label_filtered):
self.scroll_to_element( self.soup_to_selenium(label_filtered) )


element = next(iter(self.web_scrap(field, scrap_type=enum.ScrapType.TEXT, optional_term="label", main_container = self.containers_selectors["Containers"], label=label)), None)
if not element:
element = next(iter(self.web_scrap(f"[name$='{field}']", scrap_type=enum.ScrapType.CSS_SELECTOR, main_container = self.containers_selectors["Containers"], label=label)), None)
Expand Down Expand Up @@ -3690,7 +3704,7 @@ def check_grid_appender(self, line, column, value, grid_number=0):
"""
self.grid_check.append([line, column, value, grid_number])

def LoadGrid(self, wait_enable = True):
def LoadGrid(self):
"""
This method is responsible for running all actions of the input and check queues
of a grid. After running, the queues would be empty.
Expand All @@ -3707,13 +3721,13 @@ def LoadGrid(self, wait_enable = True):
>>> oHelper.CheckResult("A1_COD", "000001", grid=True, line=1)
>>> oHelper.LoadGrid()
"""
if wait_enable:
self.wait_element(term=".tgetdados, .tgrid, .tcbrowse", scrap_type=enum.ScrapType.CSS_SELECTOR)

x3_dictionaries = self.create_x3_tuple()

initial_layer = 0
if self.grid_input:
self.wait_element(term=".tgetdados, .tgrid, .tcbrowse", scrap_type=enum.ScrapType.CSS_SELECTOR)

if "tget" in self.get_current_container().next.attrs['class']:
self.wait_element(self.grid_input[0][0])
soup = self.get_current_DOM()
Expand Down

0 comments on commit 516965a

Please sign in to comment.