Cypress Error for a simpe cy.visit()
See original GitHub issueCypress throwing error for a simple method
cy.visit('http://demo.automationtesting.in/')
Current behavior:
My Current Code :
describe('Demo Automation Testing', () => {
it('Register Page', () => {
cy.request('http://demo.automationtesting.in/')
cy.visit('http://demo.automationtesting.in/')
})
})
Error :
visit http://demo.automationtesting.in/
**CypressError**
The following error originated from your application code, not from Cypress.
> Script error.
Cypress detected that an uncaught error was thrown from a cross origin script.
We cannot provide you the stack trace, line number, or file where this error occurred.
Check your Developer Tools Console for the actual error - it should be printed there.
It's possible to enable debugging these scripts by adding the crossorigin attribute and setting a CORS header.
When Cypress detects uncaught errors originating from your application it will automatically fail the current test.
This behavior is configurable, and you can choose to turn this off by listening to the uncaught:exception event.Learn moreLearn more
Stack Trace-
at cypressErr (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:171356:17)
at Object.errByPath (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:171411:11)
at Object.createUncaughtException (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:161127:46)
at $Cy.onUncaughtException (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:168996:25)
at onError (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:168058:40)
From previous event:
at run (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:168400:20)
at $Cy.cy.<computed> [as request] (http://demo.automationtesting.in/__cypress/runner/cypress_runner.js:168852:12)
From Your Spec Code:
at Context.eval (webpack:///cypress/integration/demoautomationtesting/register.spec.js:5:12)
Desired behavior:
Cypress should open the given webpage and pass the testcase
Test code to reproduce
Very simple Project.
- Opened VS Code with new project.
- ran npm init
- ran npm install cypress
- under cypress>integration>demoautomationtesting>register.spec.js
Enter Code
/// <reference types="cypress" />
describe('Demo Automation Testing', () => {
it('Register Page', () => {
cy.request('http://demo.automationtesting.in/')
cy.visit('http://demo.automationtesting.in/')
})
})
- ran npx cypress open with Chrome 84
- clicked on register.spec.js
PLEASE NOTE : When i try the URL : https://www.google.co.in it works fine.
For Better reproduction, please try below forked repo: npx cypress run Please Fork or Clone https://github.com/ManjunathPrabhakar/cypress-test-tiny to reproduce.
Versions
Cypress 5.0.0 Windows 10 Chrome 84 (When i ran with GUI Runner in original project) Edge Headless (When ran in https://github.com/ManjunathPrabhakar/cypress-test-tiny)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Error Messages | Cypress Documentation
cy.visit() failed because you are attempting to visit a different origin domain. Note. This error only pertains to Cypress version v11.0.0 ...
Read more >Cypress - cy.visit() failed trying to load - Stack Overflow
Maybe someone had the same issue we were facing which is that the cypress.json file was not in the root. We had it...
Read more >cypress-io/cypress - Gitter
I am trying to spin up my first ever test with Cypress and I am kinda bummed at not being able to get...
Read more >Fixing Cypress cross-origin errors - Reflect.run
... avoiding cross-origin errors in Cypress tests via the cy.origin() ... simple example that demonstrates a cross-domain error in Cypress.
Read more >How to handle Errors in Cypress | BrowserStack
Cypress provides the option failOnStatusCode: false, where you need to pass this option to cy.visit() command. Example: Webpage throwing 400 Bad ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your quick response and resolution. Closing this issue.
@csvan Thank you! it worked. I tired below
Approach 01
Approach 02
Also do let me know if there is a better way to handle these types. We can close the issue.