Skip to content

Indirect navigation to external website causes Error: Execution context was destroyed, most likely because of a navigation. #427

Description

@ardislu

Steps to reproduce the issue:

  1. Create index.html:
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>External Navigation Test</title>
</head>

<body>
  <a href="https://example.com">Click me</a>
</body>

</html>
  1. Create example.goml:
goto: "file://" + |PWD| + "/index.html"
click: "a"
wait-for-document-property: {"URL": "https://example.com/"}
assert-document-property: {"URL": "https://example.com/"}
  1. Run the test case:
browser-ui-test --variable PWD $PWD --test-files ./example.goml

Expected result: test case completes successfully

Actual result: test case returns this error:

(line 5) Error: Execution context was destroyed, most likely because of a navigation.: for command `wait-for-document-property: {"URL": "https://example.com/"}

This issue arises because Page.waitForNavigation() is not called in wait-for-document-property.

As a workaround, you can hardcode a duration to wait for the external navigation to finish loading:

goto: "file://" + |PWD| + "/index.html"
click: "a"
// wait-for-document-property: {"URL": "https://example.com/"}
// Workaround:
wait-for: 2000
assert-document-property: {"URL": "https://example.com/"}

However, this workaround is not optimal because it unnecessarily increases the required testing time when the external page loads quickly, and falsely fails the test when the external page loads slowly.

Long-term solution should be adding the ability to call Page.waitForNavigation() somewhere in the .goml file.


Related discussion: rust-lang/rust#106391 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions