Use the element exist activity inside the attach window, if the element is not appears then the output of element exist is Boolean. After that place If condition which boolflag = false then give the throw activity in then block. In throw write the business expection.
New BusinessRuleException(“URL is invalid”)
It throws the business exception with the message.
Set it to System.Exception so it’ll catch anything. Force the kind of error you are trying to handle. In a Log Message put exception.GetType and then you’ll be able to see the exact exception type. Then you can change the catch to that exception type.
That being said, it’s better to manually check if the page loaded correctly, using Check App State. Use it to look for a page element that indicates the page successfully loaded. In the “does not appear” block Throw your own Business Exception (invalid URL provided).
You have already encapsulated the attach window activity with Try catch activity. If any exception is thrown by the activity weather it is business or system exception it will catch in the catch block. In the Catch block you can give the log message to print the exception in the Output panel.
In the log message give like this
Exception.message to know the error.
Exception.Source to print the location of the activity which throws the error.
Unfortunately, I can’t manage to catch the 404 error when an invalid URL is fed to the process. The Open Browser activity is in the catch, but the process is interrupted nonetheless. So I can’t, for example, perform an Element Exist activity if the website doesn’t exist in the first place.
If I put, in this example, the faulty input field into the catch it works as expected if the URL is correct (see the alternative “exception handling as expected” flow in validate site url.xaml (18.2 KB)
).
But I don’t see how to catch the Open Browser or Attach Window activities if the URLs are not correct.
What am I missing?
You don’t look for the invalid URL. The first activity inside the Open Browser should be a Check App State that looks for a page element that indicates the page successfully loaded.
Idea is like this…manually would you understand a url is correct or wrong by looking at url? no
so even through automation after opening url…you have to check for something that you would expect or some error message so that if required is found page is loaded…or if error is found can throw error…either ways you can know…so a element exists or check app state is needed
Hi Paul, I don’t find those modern activities. Are they in the StudioX environment? I have created my application some years ago, so I seem to have missed some new developments.