cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.18k forks source link

Cypress can't open a App Builder Page in Salesforce #27839

Closed Rogeriohsjr closed 7 months ago

Rogeriohsjr commented 1 year ago

Current behavior

Hi There,

I am trying to run cypress in Salesforce using Salesforce Classic Experience and I am getting the error below:

image

Error stack:

`The following error originated from your application code, not from Cypress.

This error was thrown by a cross origin page. If you wish to suppress this error you will have to use the cy.origin command to handle the error prior to visiting the page.

cy.origin('https://xxx.my.salesforce.com', () => {

cy.on('uncaught:exception', (e) => {

if (e.message.includes('Things went bad')) {

  // we expected this error, so let's ignore it

  // and let the test continue
  return false
}

})

})

cy.visit('https://xxxx.my.salesforce.com/home/home.jsp')

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`

I have tried to disable the chromeWebSecurity, but didn't work out. I have tried to use origin as the error suggested, and didn't work, I need to use visit since I need to pass parameter in the URL(/secur/frontdoor).

I think the problem is that after salesforce authenticate, then I go to 'https://xxxx.my.salesforce.com/home/home.jsp' and after that salesforce goes to another domain('https://xxxx.my.file.com) to do some other business there, and then I get the error. I can't change salesforce behavior, so I was wondering if there is a flag somewhere in cypress that doesn't limit the app to use different domains.

Desired behavior

I should be able to load salesforce page using classic layout.

Test code to reproduce

To reproduce this issue you can:

  1. Fork the repository below and follow the steps

https://github.com/Rogeriohsjr/cypress-salesforce

  1. Do all the steps and make sure you can connect to sf using LEX (Lightning Experience)

  2. Now let's change the baseURL in cypress.config.js to https://xxx.my.salesforce.com/, xxx is your orgs name same pattern that you have in lightning which was https://xxxx.lightning.force.com/

You can login manually to your org and click to your profile, then you have an option Switch to Salesforce Classic.

image

  1. Now run the test called "sf-classic-account-page.cy.js" which should show the error.

Cypress Version

10.9.0

Node version

18.14.2

Operating System

Windows

Debug Logs

No response

Other

No response

nagash77 commented 1 year ago

Hi @Rogeriohsjr , unfortunately we do not have a salesforce instance to test against so we won't be able to replicate this issue. I do see that you are using a version of Cypress that is quite old at this point. Can you please try upgrading to the latest to see if that resolves your issues? We have addressed many Salesforce specific problems since 10.9.0.

Rogeriohsjr commented 1 year ago

Hi @nagash77 , thanks for replying, sorry about the confusion but I am using the 13.2.0 cypress version, when I was opening the issue I noticed that then I updated to see if the issue persists and it does, I forgot to update the github issue.

Regards to salesforce access, you can create your own instance, the steps in the repository is showing the link how you can create that, it is very straight forward after you fill the form you will get a link in your email with an instance. Salesforce provides a dev org for free so anyone can use that.

Let me know if that helps, thanks.

cypress-app-bot commented 7 months ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

cypress-app-bot commented 7 months ago

This issue has been closed due to inactivity.