![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
|
Hi, just wondering if there is a way to intentionally throw an error. I have a task that scrapes data from a webpage and I want it to throw an error if the page doesn't load properly. I've created the if statement that checks to see if the page is loaded the way it expects it, but I don't know how to throw an error within the if/end if. If there isn't any way built into AA to do this I could just get it to do something that will cause an error... if that is the case, what would suggest? Thanks! Tyler |
| |||
|
I'm not sure I understand what you're trying to achieve. If you want the error to stop the task then place 'stop task' within the if statements. If you want to log the error then you can use 'error handling' or 'log to a file' within the if containing the error variables. If you want to display the error you can use 'message box' to display the error. |
| |||
|
Ya it seems a bit odd, and it may not be the best way to do it... but here's why I want to do it. I am using error handling that is set to continue the task and send an email with a screen shot of the error that it experiences. This great because it lets me see what was going on at the time the error occurred. In my example, I want to see what the web page contained at the time of the error. I could use the snapshot feature and save the snapshot (screenshot) locally then send an email with the snapshot as an attachment... but throwing an error is just quicker at would do all of those steps in one... so I wanted to do that. |
| |||
|
Hello, What you can try is, . Create a variable say $ThrowError$ of value type. . After you validate the page is not loaded properly, inside If-EndIf block assign 'True' to $ThrowError$ variable else assign 'False' to same. . Then using 'If Variable' command check if $ThrowError$ = 'True' then using 'Message Box' command you can throw customized error and right after that stop the task using 'Stop Task' command. The text format of commands would appear something like this, Variable Operation : False To $ThrowError$ If Web Control Exists Then Variable Operation : True To $ThrowError$ Else Variable Operation : False To $ThrowError$ End If If $ThrowError$ Equal To "True" Then Screen Capture: Capture Window "* Windows Internet Explorer" and store in "C:\Image.png" Send Email: Subject: "Automation Anywhere finished executing the task. with Attachment(s)" Message Box: "Page not loaded properly. Aborting the task." Stop The Current Task End If Hope that helps. |
| |||
|
Thanks forumsupport, that's I was talking about when I said: "I could use the snapshot feature and save the snapshot (screenshot) locally then send an email with the snapshot as an attachment... but throwing an error is just quicker at would do all of those steps in one... so I wanted to do that." Trenton, I was hoping to invoke the error handling... so by throwing an error, I mean I wanted to somehow cause the error handling to think that there was an error... so it would react the same way it does when there is an actual error... like say when it can't find a web control on a page. That way I could take advantage of the error handling features which automate the steps taken in forumsupports suggestion above. Perhaps that is bad form... but thought I'd see if it was possible. Thanks for your helping out!! |
| |||
|
Just to follow up with this, I have learned that I can throw an error and invoke error handling by putting in a intentionally incorrect db connection string. This will cause and error and invoke the error handling that your db connection in enclosed within.
|
| |||
|
Hey Phil, good idea... I'd test it out but my current solution of the invalid database connection is working great and it happens very fast. I seem to recall AA waiting a while before giving up on a non-existent window... but I might be wrong there.
|
![]() |
| Thread Tools | |
| Display Modes | |
| |