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
Support it.
3.3.1
You can visit a file by specifying the relative path to cy.visit()
- relative to the projectRoot.
cy.visit('./test.html')
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
What's the status of this request? A response has been given that does not answer the original question. Other users have commented about the same issue:
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.htmlI was expecting file://./cypress/screenshots/screenshot.html
This issue is still in the 'proposal' stage, which means no work has been done on this issue as of today, so we do not have an estimate on when this will be delivered.
@jennifer-shehane could you clarify if visiting file relative to project root is possible or not?
According to docs https://docs.cypress.io/api/commands/visit.html#Web-Server it should be, but it still appends base url
@levenleven It is possible and does work if you do not have a baseUrl
defined.
Reopening as this is still an existing issue that needs addressing. If you'd like to no longer be notified in this thread, please Unsubscribe from notifications on the right side of this issue.
Sorry, this is actually a duplicate of #2918 馃槤 Forgive my comment spamming.
Most helpful comment
You can visit a file by specifying the relative path to
cy.visit()
- relative to the projectRoot.