Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ardislu opened this issue Jan 5, 2023 · 0 comments · Fixed by #438

Comments

@ardislu
Copy link
Contributor

ardislu commented Jan 5, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant