Article Overview:
This article will cover how you can solve the following issue:
Users may encounter the following error message during the execution of their Journey:
"We are sorry, but due to an unexpected event, we could not execute this journey to completion. Please try again by re-executing this journey."
Problem Statement:
Journey execution is failing due to an unexpected event, causing interruptions and preventing completion.
Root Cause:
The issue arises from a page freeze related to PDF file downloads that occur in new browser tabs. When links attempt to open PDFs or other files in a new tab, the Journey execution gets delayed or stuck, leading to the unexpected error.
Solution:
We can make following changes in journey to solve this issue:
-
Add Falsy Condition:
By including a falsy condition, the Journey will no longer wait indefinitely for conditions that may not be met. This prevents the execution from being delayed or stuck when problematic elements, such as links opening in new tabs, are encountered.
Example Action: Add a condition to check that the element or link is clickable, and stop the wait if it’s not. -
Execute Script Step:
Use a script to remove the
target="_blank"
attribute from links. This ensures that PDF links (or any external links) will open in the same tab instead of a new one. This allows the Journey to continue without any interruptions.
Example:Execute "[...document.querySelectorAll('a[target=\"_blank\"]')].forEach(e=>e.removeAttribute('target'))"
. -
Mouse Click Step:
Add a Mouse Click step to simulate a click action on the link. This ensures that the Journey does not rely on the browser’s default behavior to open links in new tabs or handle pop-ups. By explicitly clicking the link, the Journey becomes predictable and avoids potential browser-specific errors.
Example Action: Add a step to click the PDF link after modifying its target attribute.
Implementation Steps in Virtuoso
-
Add a falsy condition to prevent the Journey from waiting indefinitely.
-
Include the script to remove
target="_blank"
attributes. -
Add a Mouse Click step to ensure the link is interacted with successfully.
References:
-
Guide on handling PDF file downloads - https://docs.virtuoso.qa/library/language-extensions/#view-pdf-files
-
Knowledge Base entry on similar issues - https://www.notion.so/virtuosoqa/Browser-hangs-when-downloading-a-file-for-example-PDF-4ca572860cd24d37b984f3d5f6e5afae
Comments
0 comments
Please sign in to leave a comment.