Closed sandyklh closed 1 year ago
Hi @sandyklh, I've had problems with Iframes and cypress in the past. this is the solution I have been using for months now and it's worked for any Iframe I've encountered so far:
Function:
const getIframeBody = (iframe) => {
//gets the body of the iframe and wraps it in a cypress understandable object
return cy
.get(iframe, { log: false })
.its('0.contentDocument.body', { log: false }).should('not.be.empty')
.then((body) => cy.wrap(body, { log: false }))
}
Usage:
getIframeBody('ifr_name').find('desired_selector').click() //replace 'ifr_name' with your Iframe selector
For you specifically:
cy.iframe().find('a[href*="cashlanding"]').eq(0).click({force: true})
becomes:
getIframeBody('#portalFrame').find('a[href*="cashlanding"]').eq(0).click()
@symon-skelly i can get to the first frame i.e. getIframeBody('#portalFrame').find('a[href="cashlanding"]').eq(0).click() but on the next page i need to click on the highlighted element above i am using getIframeBody('#portalFrame').find('a[href="statementCredit.htm"]').eq(0).click() but again i am getting error
as
Timed out retrying after 8000ms: Expected to find element: a[href*="statementCredit.htm"], but never found it. Queried from element:
Please help!!! Thanks in Advance!!
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.
This issue has been closed due to inactivity.
Hi , I am new to cypress , and i am stuck with using frames
Current behavior
i am trying to find an element within the iframe but could not find it. Giving error as Timed out after 8000s. Expected element not found. The concern is its not able to locate the item even after wrapping the body inside the frame. i am using the cypress-iframe plugin. Trying to click on the button with frame id portalFrame
Desired behavior
As per expectations it should be able to click on button present within the frame.
Test code to reproduce
Error Msg:
Timed out retrying after 8000ms: Expected to find element: a[href*="statementCredit.htm"], but never found it. Queried from element:
Versions
Version: 6.8.0
HTML: