Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR - number of step { does not tally with with }, nested code blocks bug - fixed #966

Closed
marcelocecin opened this issue Mar 12, 2021 · 8 comments
Assignees
Labels

Comments

@marcelocecin
Copy link

hello the error is occurring: ERROR - number of step {does not tally with with}
this is part of my code:

total = count('//*[@class="mr9 "]')
dump Data,PDF to file.csv
if total greater than or equals to 1
  for n from 1 to total
    click (//*[@class="mr9 "])[`n`]
    wait 5
    read (//tr[@class="expansive"]//td[4])[`n`] to data
    click (//*[@class="mr9 "]/..//*[@class="noClick"]//input[`n`])[3]
    wait 5
    popup saveAsFile.jsf
      click PDF.png
      wait 5
      keyboard [ctrl]w
    py begin
    import glob
    print(glob.glob("/home/rpa/Downloads/tagui/flows/samples/*.PDF")[0])
    py finish
    wait 1
    line = [data, py_result]
    write `csv_row(line)` to file.csv
wait 5
dom window.history.back()
@kensoh
Copy link
Member

kensoh commented Mar 13, 2021

Hi Marcelo! I can replicate. When I remove the block of code py begin .. py finish it works. Will check more.

@kensoh kensoh self-assigned this Mar 13, 2021
@kensoh kensoh changed the title ERROR - number of step { does not tally with with } ERROR - number of step { does not tally with with } - investigating further Mar 13, 2021
@kensoh kensoh changed the title ERROR - number of step { does not tally with with } - investigating further ERROR - number of step { does not tally with with } - bug? investigating further Mar 13, 2021
@kensoh kensoh added the bug label Mar 13, 2021
@kensoh
Copy link
Member

kensoh commented Mar 13, 2021

While figuring out more on this, can you try below to see if it works for you?

Below block can be runnable by me, the change I made is use py step directly instead of py begin and finish.

total = count('//*[@class="mr9 "]')
dump Data,PDF to file.csv
if total greater than or equals to 1
  for n from 1 to total
    click (//*[@class="mr9 "])[`n`]
    wait 5
    read (//tr[@class="expansive"]//td[4])[`n`] to data
    click (//*[@class="mr9 "]/..//*[@class="noClick"]//input[`n`])[3]
    wait 5
    popup saveAsFile.jsf
      click PDF.png
      wait 5
      keyboard [ctrl]w
    py import glob
    py print(glob.glob("/home/rpa/Downloads/tagui/flows/samples/*.PDF")[0])
    wait 1
    line = [data, py_result]
    write `csv_row(line)` to file.csv
wait 5
dom window.history.back()

@marcelocecin
Copy link
Author

hi @kensoh it worked !
would there be another more practical way to search for the path of the last downloaded file?
thanks !

@kensoh
Copy link
Member

kensoh commented Mar 13, 2021

Hi Marcelo, if you meant just the folder name, it would be in the flow_path variable. If you want the full filename you can try something like below using run step to use the OS commands to return what you need.

for windows

run cmd /c dir parameters *.PDF
echo `run_result`

for macos/linux

run ls parameters *.PDF
echo `run_result`

Note that the working folder for run step is in tagui/src folder.

@marcelocecin
Copy link
Author

marcelocecin commented Mar 13, 2021

Hi Ken
I ended up using python, here is my code:

    py import glob, os
    py list_of_files = glob.glob("/home/rpa/Downloads/tagui/flows/samples/*.PDF")
    py latest_file = max(list_of_files, key=os.path.getctime)
    py print(latest_file)

thanks

@kensoh
Copy link
Member

kensoh commented Mar 13, 2021

Using Python seems like the most straightforward haha.

TagUI has the fs module inherited from PhantomJS, but the list() does not sort by file date -
https://phantomjs.org/api/fs/method/list.html

Following on mac will return the filename of the latest file created. But I'll prefer the Python method than this.

run ls -lt
echo `run_result.split('\n')[1].split(' ')[run_result.split('\n')[1].split(' ').length-1]

kensoh added a commit that referenced this issue Mar 13, 2021
@kensoh
Copy link
Member

kensoh commented Mar 13, 2021

Above commit seems to solve the problem by handling nested code blocks correctly. You can download the latest copy of TagUI with this fix and unzip to overwrite your existing installation (please drag the folders under tagui\src to overwrite your existing installation) - https://github.com/kelaberetiv/TagUI/archive/master.zip

In the next release, this fix will become part of the packaged zip files. Thanks Marcelo for spotting and reporting this bug!!

@kensoh kensoh changed the title ERROR - number of step { does not tally with with } - bug? investigating further ERROR - number of step { does not tally with with } - fixed nested code blocks bug Mar 13, 2021
@kensoh kensoh changed the title ERROR - number of step { does not tally with with } - fixed nested code blocks bug ERROR - number of step { does not tally with with }, nested code blocks bug - fixed May 25, 2021
@kensoh
Copy link
Member

kensoh commented Jun 18, 2021

Closing issue, change included in latest packaged release - https://github.com/kelaberetiv/TagUI/releases/tag/v6.46.0

@kensoh kensoh closed this as completed Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants