-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to access Salesforce Lightning elements by default #29294
Comments
Same issue on [email protected] |
I confirmed this is happening and reproducible given the example. There's this call, where we call into jquery with the selection and the 'scope', where it's failing within jquery in that call. https://github.com/cypress-io/cypress/blob/remove-json-lint/packages/driver/src/cy/commands/querying/querying.ts#L198 I have a hunch that maybe we're not finding all the shadow dom to pass through the scope here? We're using a pretty old version of jquery here also that may not be helping. |
I am also struggling with not being able to access Salesforce Lightning elements from my Cypress tests. I can interact with the elements within the Cypress test runner but any method and configuration I've tried, I get "timeout" because the element is not found. Is there any hope that this will be addressed soon? |
@jennifer-shehane
|
@jennifer-shehane @kathleennaughton This actually gets around the issue // Do the login to salesforce above the fix
cy.then(() => {
const doc = top.document.querySelectorAll(`iframe[id="Your project: 'Test Project'"]`)[0].contentDocument
doc.querySelector = document.querySelector.bind(doc)
doc.querySelectorAll = document.querySelectorAll.bind(doc)
})
cy.get('[title="Controller"]').click() More fixes - #29294 (comment) ^ I also notice that |
@jennifer-shehane @kathleennaughton Can confirm that the above fix actually works on a real Salesforce page |
I will try this in the next couple of days. I have project commitments I want to get completed before I get to this.
Regards,
Kathleen
…________________________________
From: Alex Schwartz ***@***.***>
Sent: Monday, September 16, 2024 12:02 PM
To: cypress-io/cypress ***@***.***>
Cc: Kathleen Naughton ***@***.***>; Mention ***@***.***>
Subject: Re: [cypress-io/cypress] Unable to access Salesforce Lightning elements even with {includeShadowDom: true} (Issue #29294)
@jennifer-shehane<https://github.com/jennifer-shehane> @kathleennaughton<https://github.com/kathleennaughton>
Can confirm that the above fix actually works on a real Salesforce page
—
Reply to this email directly, view it on GitHub<#29294 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BI5MBTEBN3UX2AKQOUY2KH3ZW4MKJAVCNFSM6AAAAABF7CGR22VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJTGU3DOOBQGM>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Please remove topic: shadow dom - this isn't really that |
fixSalesforce() {
// Workaround for Salesforce breaking "cy.get" with most lightning elements
cy.document().then(doc => {
doc.querySelector = document.querySelector.bind(doc)
doc.querySelectorAll = document.querySelectorAll.bind(doc)
doc.getElementById = document.getElementById.bind(doc)
doc.getElementsByClassName = document.getElementsByClassName.bind(doc)
doc.getElementsByName = document.getElementsByName.bind(doc)
doc.getElementsByTagName = document.getElementsByTagName.bind(doc)
doc.getElementsByTagNameNS = document.getElementsByTagNameNS.bind(doc)
doc.getRootNode = document.getRootNode.bind(doc)
})
} |
Any update on this? I have struggling with this for so long |
@alexsch01 This workaround makes a lot of sense to me. Salesforce does the absolute strangest things we have ever seen on a website. Nearly overwriting all default methods. So many things don’t function right when querying into their website. |
UPDATE
See #29294 (comment) for workaround
Current behavior
Test code to reproduce
Cypress Version
13.7.0
Node version
v18.13.0
Operating System
Windows 10.0.19045.4170
Other
Repo for Cypress test: https://github.com/alexsch01/cypress-repro-salesforce
The text was updated successfully, but these errors were encountered: