When navigating URL from Excel. How can I throw exception when URL wrong/invalid/page not found/etc ??
Assuming you are navigating URL from Excel using Use application/browser activity. Here you have the below approaches to handle the URL wrong/invalid/page not found etc.
- Use Try/Catch Block:
- Wrap your navigation activities within a
Try/Catchblock. - This will allow the process to handle exceptions when an invalid URL is encountered.
- Check App State Activity:
- Use the
Check App Stateactivity to verify the presence of an element that indicates the successful loading of the page. - If the element is not found, you can throw a custom exception.
- Use Element Exists Activity:
- Place an
Element Existsactivity right after theOpen Browseractivity. - If the element indicating a successful page load does not appear, this activity will return
false.
- Throw Custom Exception:
- If the
Element Existsreturnsfalsein theIfcondition, throw a custom business exception using theThrowactivity. - Example:
Throw New BusinessRuleException("URL is invalid").
Hey @Royy_B simply use use browser or else open browser and surround one of these activity you are working with Try Catch and in the Catch Section Use Throw activity and pass New BusinessRuleException(“Write your Own Custom Exception”).
cheers Happy Automation