cypress-io / cypress

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

Salesforce returns Component Error under the Cypress test #21233

Closed tit closed 1 year ago

tit commented 2 years ago

Current behavior

Hello, I try to open Salesforce page with Lightning Web Security (https://developer.salesforce.com/docs/component-library/documentation/en/lwc/lwc.security_lwsec_intro). But under Cypress Salesforce returns Component Error. If I use Playwright, then Salesforce not returns this error.

cypress playwright

Desired behavior

No response

Test code to reproduce

describe('playground', () => {
  it('playground', function () {
    cy.request({
      body: {
        display: 'page',
        hasRememberUn: true,
        height: '1080',
        lt: 'standard',
        pw: Cypress.env('password'),
        un: Cypress.env('email'),
        useSecure: true,
        username: Cypress.env('email'),
        width: '2560',
      },
      form: true,
      method: 'POST',
      url: 'https://login.salesforce.com',
    })

    cy.visit('https://incountrycom-dev-ed.lightning.force.com/lightning/n/TestCypressPage')
  })
})

I can provide credentials from Salesforce Instance in a personal email message.

Cypress Version

9.6.0

Other

No response

AtofStryker commented 1 year ago

@tit can you see if this is fixed by https://github.com/cypress-io/cypress/issues/24290#issuecomment-1376214221 in 12.4.0 on release a week from Tuesday?

AtofStryker commented 1 year ago

Going to close this issue due to inactivity, but if this continues to be a problem please open another issue!

enesyildir commented 1 year ago

Hello, I am using 12.4.0 cypress version, and I still see this error in my tests

AtofStryker commented 1 year ago

Hi @enesyildir. Did you try 12.4.0 with the experimentalSkipDomainInjection configured for your test domain?

enesyildir commented 1 year ago

@AtofStryker Hello, that fixed the chrome issue, but this component error still happens when I run my tests.

AtofStryker commented 1 year ago

@enesyildir I have reopenned the issue. Would you be able to to provide salesforce credentials so we can access the reproduction site?

jeanabanto commented 1 year ago

I am getting a similar error, currently running in 12.8.1. Haven't tried with other test frameworks, but so far we can't reproduce it manually.

Screenshot 2023-03-21 at 1 41 54 pm
jeanabanto commented 1 year ago

Tried running the same tests that are producing the component error on Firefox, and the popup error does not appear. Seems like this is another error on Salesforce that only happens in Chromium browsers.

It still shows there is an uncaught exception in the logs when running on Firefox, but (fortunately) it doesn't prompt the component error that can block elements under test.

Screenshot 2023-03-22 at 11 54 53 am
AtofStryker commented 1 year ago

@jeanabanto Are you able to create a reproduction repository we can run on our end to validate the issue?

jeanabanto commented 1 year ago

@AtofStryker I am unable to create a reproduction repository without giving out access to our internal APIs and applications. The error appears only on specific scenarios within our application that runs on salesforce. Enabling chromeWebSecurity to true however, prevents the pop-up error (similar behaviour on Firefox where there is no configuration to disable the same origin policy).

AtofStryker commented 1 year ago

@jeanabanto interesting. Just to clarify, are you setting chromeWebSecurity to true or false?

jeanabanto commented 1 year ago

@AtofStryker by default in our config file, chromeWebSecurity is false since several tests involving iframes require this configuration. Now to prevent the popup component error, we need the chromeWebSecurity to be true.

jennifer-shehane commented 1 year ago

Right now there doesn't seem to be enough information to reproduce the problem on our end. We'll have to close this issue until we can reproduce it. This does not mean that your issue is not happening - it just means that we do not have a path to move forward.

Please comment in this issue with a reproducible example and we will consider reopening the issue. Here are some tips for providing a Short, Self Contained, Correct, Example and our own Troubleshooting Cypress guide.