I am trying to automate file uploading via cypress but getting the error below.
I am not finding the root cause of the issue.
enter code here
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
Below is my code
it('Single File Upload-DOM', () => {
cy.visit('http://127.0.0.1:5500/Help%20Folder/fileupload.html')
cy.get('#file-upload1').attachFile('dog_small.jpg')
cy.get('span#fileName1').should('have.text','dog_small.jpg')
});
You can turn off the exception check globally by writing:
Cypress.on('uncaught:exception', (err, runnable) => {
return false
})
under cypress/support/index.js
Related
I'm writing automated tests for a Shopify application using cypress
When I finish filling the cart with items then click on the checkout button, I got this kind of error that prevents me to go to the checkout page :
(uncaught exception) Error: undefined status[500] response [{"message":"Experience not defined"}]
The following error originated from your application code, not from Cypress.It was caused by an unhandled promise rejection.
>undefined status[500] response [{"message":"Experience not defined"}]
When Cypress detects uncaught errors originated 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.
This is the line when it heppens :
cy.get('.cart__checkout-form >
.button').scrollIntoView().click({force:true});
I am trying to automate uploading a picture on a website. I can manually upload fine. But when I do it using Cypress and node module cypress-file-upload, I get 500 server error.
I have import 'cypress-file-upload'; in commands.js file. I have
Cypress.on('uncaught:exception', (err, runnable) => {
return false;
});
I get application threw an error if I do not have this exception code.
This is what my code looks like for upload
cy.fixture('settings.JPG').then(fileContent => {
cy.get('[id="xyz"]').attachFile({
fileContent: fileContent.toString(),
fileName: 'settings.JPG',
mimeType: 'image/png'
});
});
As I look at browser where cypress is running, I can see, file is being attached near the Choose file field. But as soon Cypress clicks on the submit button, it throws 500 error
If I go to Cypress view pane and click on the submit button, it throws 500 error again
But if I click on the choose file and select the same file and then click on Submit button, then I do not get 500 error and it works.
Can anyone point out why I am getting 500 error? and what can I do to get past this? Thanks a bunch in advance.
Try to replace your mimeType as a image/jpg.
I've been running into a problem with Cypress (currently v8.3.1 but this has been a constant for years) where my test detects a cross origin error on page load, but I am 99% certain that shouldn't apply.
The test logs into a web application and attempts to access a project.
cy.visit(webapp) //login page
cy.login(userCreds) //enter user cred and access main page
cy.get(projectAcccessButton).click() //access project from main
As the project page loads, Cypress throws the cross origin error below. I've been using the "chromeWebSecurity": false workaround, but it does not apply to Firefox. Firefox test coverage is on the "2022 To Do" list, so I am turning to Stack for answers - I hope.
What I want to do: Access the project page without issue.
What has been happening: cross origin error on page load
Permission denied to access property "document" on cross-origin object
I mentioned that the cross origin error likely shouldn't apply because when I modify the test to access the project page via cy.visit(), Cypress does not throw an error.
cy.visit(webapp) //login page
cy.login(userCreds) //enter user cred and access main page
cy.visit(projectPage) //access project via url
This leads me to believe something is happening on the button click that is somehow triggering the cross origin error. Is it possible that the button attribute onclick="window.location.href='/projectManager/123456789'" is somehow being interpreted as leaving the main origin?
If this error is related to the window.location.href, how can I resolve this so Cypress doesn't detect an error when running in Firefox?
Full Error Message:
I've just upgraded all my react native app packages and now I'm getting this error when running the app in Xcode:
INFO : BSG_KSCrashReport.c (1513): void bsg_kscrashreport_writeStandardReport(BSG_KSCrash_Context *const, const char *const): Writing crash report to /Users/Library/Developer/CoreSimulator/Devices/123/data/Containers/Data/Application/123/Library/Caches/KSCrashReports/foo/foo-123.json
2021-06-23 15:18:32.196550+1000 foo[12206:1933872] *** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: Error: Minified Redux error #12; visit https://redux.js.org/Errors?code=12 for the full message or use the non-minified dev environment for full errors. ', reason: 'Unhandled JS Exception: Error: Minified Redux error #12; visit https://redux.js.org/Errors?code=12 for the full message or use the non-minified dev environment for full errors..., stack:
Redux error 12 state:
The slice reducer for key "" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.
I'm using rematch. If I look at all my generateModel functions they all provide a valid initialState.
Where can I start looking to debug this?
I'm a Rematch maintainer, if you want to provide a valid reproduction repo inside Rematch repo or here we'll be happy to help.
Rematch changed a lot internally from v1 to v2, not too much for end users, but probably there's something that you need to fit to make it runnning fine again :)
I'm trying to use the React and JavaScript SDKs for Optimizely, but getting the following error in the console:
OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
More info about my setup below:
Installed via Yarn: yarn add #optimizely/react-sdk
Import statement in the app container:
import {
createInstance
} from '#optimizely/react-sdk'
Logic in render function:
const optimizely = createInstance({
sdkKey: '<SDK_KEY>',
})
const enabled = optimizely.isFeatureEnabled('example_feature', 'user123');
I get this error in the Chrome console:
OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
The Optimizely object will log that error when you call isFeatureEnabled before the SDK has successfully loaded your project's datafile. This can happen for a number of reasons outlined below. Looking at the code example provided in the question, it looks like reason #4 is the most likely cause of the error, but here are all of them:
1. Bad SDK key
If you pass in a bad SDK Key to createInstance, the SDK will not successfully load the datafile and you will get this error.
const optimizely = createInstance({
sdkKey: 'invalid-sdk-key'
})
2. Malformed datafile
If you are passing in the datafile directly to createInstance, but pass in an object that isn't the proper datafile format, you will get this error:
const optimizely = createInstance({
datafile: { wrong: 'format' }
})
3. Inaccessible datafile
Make sure you can access the url of your datafile in a web browser: https://cdn.optimizely.com/datafiles/<Your_SDK_Key>.json. If you get an AccessDenied (403) or Not Found (404) error and your account is new, make sure you create something in the Optimizely UI so that Optimizely is triggered to create and upload a proper datafile.
If in the console of your running application you see a 403 or 404 for the request to the datafile, ensure there are no ad-blockers, firewalls, or proxies preventing the SDK from requesting the datafile on Optimizely's CDN from the SDK.
4. Not waiting for Optimizely SDK to be ready
Even if you have the right SDK Key and the SDK can access Optimizely's CDN. If you don't give the SDK enough time for the datafile request to finish, you will be trying to use the SDK before it's ready.
In the JavaScript SDK, this can be solved by using the onReady method:
const optimizely = createInstance({
sdkKey: 'valid-sdk-key',
});
optimizely.onReady().then(() => {
// optimizely is ready to use, with datafile downloaded from the Optimizely CDN
});
If using the <OptimizelyFeature> component of the React SDK, then the <OptimizelyFeature> component will automatically wait until the <OptimizelyProvider> has successfully loaded the datafile before evaluating isFeatureEnabled.
My Firefox console error was
[OPTIMIZELY] - ERROR <timestamp> OPTIMIZELY: Optimizely object is not valid. Failing isFeatureEnabled.
One of my network failures gave me a big clue. The GET request for cdn.optimizely.com showed "Blocked by AdBlocker Ultimate" under the Transferred column.
Solution
I turned off my ad blocker for this site.