我正在启动页面https://www.nasdaq.com/。之后,我还要等待5秒钟来加载页面。之后,我想检查页面是否存在,或者是否加载,然后抛出异常。因此,在这种情况下如何以及何时使用异常处理。见所附图片。我尝试将恢复,恢复,异常阶段放在启动阶段以及等待阶段。但我不知道在哪里放置例外。
首先,在完全必要之前不要使用任意的(固定的)等待阶段。而是使用智能的等待阶段,这意味着等待某些事情发生,然后继续执行或在超时时引发异常。在您的情况下,您可以使用智能等待阶段来检查网站是否已加载。
When it comes to throwing an exception, in your case I would just simply launch, then wait for the document to be loaded and throw an exception if it times out. See below diagram.
Also, I would leave retry logic (recover - resume) for the process layer. Object should ideally contain small reusable actions and no business logic, so decisions if and how many times to retry should be taken in the Process.