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

Try catch to catch errors in TagUI during automation #148

Closed
kensoh opened this issue Apr 30, 2018 · 4 comments
Closed

Try catch to catch errors in TagUI during automation #148

kensoh opened this issue Apr 30, 2018 · 4 comments
Labels

Comments

@kensoh
Copy link
Member

kensoh commented Apr 30, 2018

Raising this issue on behalf of user email so that other users can benefit -


In Sikuli there is “Try Catch” error-handling command https://answers.launchpad.net/sikuli/+question/229988.

Does TagUI have something similar?

@kensoh kensoh added the query label Apr 30, 2018
@kensoh
Copy link
Member Author

kensoh commented Apr 30, 2018

Can you tell me more about your use scenario? JavaScript has try-catch blocks, but it probably can't catch when an UI element cannot be found. Because when the element cannot be found, that scenario has been pre-planned and an error message is shown instead.

Right now, I'm working on a major rewrite of TagUI. I notice some situations where the execution order is not sequential, so am rewriting the internal design so that it is more deterministic and can make use of if and else statements better.

Of course, the rewrite I am working to maintain backward compatibility of existing scripts as priority, while finding ways to work around JavaScript technical limitations. An example of specific scenarios where the execution order is not perfect is below. It outputs 1, 3, 2. The rewrite aims to address this.

Not sure if you have come across some behavior like below while you develop automations for your scenarios?

echo '1'
if (true)
{
echo '2'
}
echo '3'

update - above-mentioned major rewrite implemented in cutting edge release - #150

@kensoh kensoh closed this as completed Apr 30, 2018
@kensoh
Copy link
Member Author

kensoh commented May 8, 2018

Response from user

The try-catch block is mainly for performing transactions in NDA – I personally encounter errors halfway through my transaction in NDA (e.g. when I switch from one page to another, error message may be encountered). So we are trying to see how we can program TagUI to “resume” the process for NDA. That said, it’s not a big issue for us since we are doing the process on a daily basis so if a client is “missed” for a particular day, it will be attempted again by TagUI the next day. So all is good :)


My response to that

I see.. That's good :)

Since we are on the topic, may I gather some more ideas from you on this try-catch thing / ability to continue running even when error is encountered?

In theory I can try adding a new option to let TagUI not quit when an error of not finding an expected element is encountered. But usual UI workflow is such that if a step is not done, subsequent steps would likely cause error data entry into the application or result in more errors.

Thus I made the default by design to quit on error. Users can also set the timeout to be much larger in tagui_config.txt or use the timeout step to temporarily set to a large number of seconds.

No need to reply, but if offhand you have more inputs or ideas on this topic, I can chew over and see if there is some improvement that I can make to TagUI to handle such scenarios.

@dinesh3434
Copy link

I believe the option to not quit on error is very much needed and should be incorporated. I have a situation where an element is not found by TagUI. If I am able to determine this, I can control the flow to use different approach like sikuli block. Believe currently this is not possible.

@kensoh
Copy link
Member Author

kensoh commented Jul 26, 2018

Hey @dinesh3434 it is bad automation program to not quit on error. If you really really want that, you can modify tagui_parse.php, search and replace '.exit()' with blank '' and it may be able to make program not quit on exit. For the current version, there should be 8 replacements of '.exit()' to blank ''.

But I wont adjust the TagUI default code base to support something like that. Because it will just lead to more badly designed automation scripts by users.

Also, you can use functions such as present(), visible() which can be used for web elements or sikuli visual automation to detect if an element is on the screen. So it should be able to be handled by good automation program design instead of relying on not exiting when error is encountered -

https://github.com/kelaberetiv/TagUI#helper-functions
https://github.com/kelaberetiv/TagUI#visual-automation

Below sample automation script shows after making above replacement, TagUI does not exit on error.

sample

https://google.com
click test_error_element
type q as testing[enter]
wait 5 seconds
click test_error2_element
click test_error3_element
echo 'end of test'

tagui sample chrome

START - automation started - Thu Jul 26 2018 22:36:19 GMT+0800 (+08)
https://google.com - Google

click test_error_element
ERROR - cannot find test_error_element
type q as testing[enter]
wait 5 seconds
click test_error2_element
ERROR - cannot find test_error2_element
click test_error3_element
ERROR - cannot find test_error3_element
end of test

https://www.google.com/search?source=hp&ei=Y9xZW6OqIYfWvgTZwomYDQ&q=testing&oq=testing&gs_l=psy-ab.12..0i131k1j0l9.13427.14059.0.14577.7.7.0.0.0.0.69.310.7.7.0....0...1c..64.psy-ab..0.7.310....0.axPdS6U6ZBI - testing - Google Search
FINISH - automation finished - 48.6s

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