question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Have a way to visit a local HTML file without prepending the `baseUrl`

See original GitHub issue

Current behavior:

If I want to open a local file for test, like: cy.visit('file:///Users/jasonzhang/Desktop/test.html')

I got an error:

CypressError: cy.visit() failed trying to load: file:///Users/jasonzhang/Desktop/test.html We attempted to make an http request to this URL but the request failed without a response. We received this error at the network level:

Error: Invalid URI “file:///Users/jasonzhang/Desktop/test.html” Common situations why this would fail:

  • you don’t have internet access
  • you forgot to run / boot your web server
  • your web server isn’t accessible
  • you have weird network configuration settings on your computer

Desired behavior:

Support it.

Versions

3.3.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

24reactions
jennifer-shehanecommented, Jun 13, 2019

You can visit a file by specifying the relative path to cy.visit() - relative to the projectRoot.

cy.visit('./test.html')
7reactions
nolimitsdudecommented, Nov 4, 2019

When I run cy.visit(‘./cypress/screenshots/screenshot.html’) the baseurl is being added and I am not on file:// https://fleetlocate-stage.spireon.com/./cypress/screenshots/screenshot.html

I was expecting file://./cypress/screenshots/screenshot.html

Using cypress 3.6.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to visit a page that is on my computer with Cypress
Learn how to test an HTML page that is only in your local environment ; Today's “Pinch of cypress” is inspired by a...
Read more >
visit - Cypress Documentation
Visit local file when baseUrl is set. If you have baseUrl set, but need to visit a local file in a single test...
Read more >
How to load a local html file in a xamarin forms webview
To display local content using a WebView, you'll need to open the HTML file ... any links to local resources in your HTML...
Read more >
The Document Base URL element - HTML - MDN Web Docs
The HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in...
Read more >
HTML and URLs
Every resource available on the Web --- HTML document, image, video clip, program, etc. --- has an address that may be encoded by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found