1

I am trying to interact with elements within a frame.

    <frame name="content" scrolling="AUTO" src="empty.jsp">
    #document
     <html lang="en">
       <head>...</head>
      <body onload="changeModelEntries(window.document.forms['mensForm'].manufacturer.options[window.document.forms['mensForm'].manufacturer.selectedIndex].value)" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
    <form name="mensForm" method="post" action="/aeu/mensSearch.do">
       <input type="hidden" name="resultsPerPage" value="25">
       <input type="hidden" name="searchName" value="getMensClothing">
       <input type="hidden" name="selectedIndex" value="-1">
       <input type="hidden" name="formContextKey" value="">

I can successfully access the frame body by using Cypress' suggested custom commands:

    //Login code here 
    const getContentFrameDocument = () => {
    return cy
      .get("frame[name=content]")
      .its("0.contentDocument")
      .should("exist");
    };

    const getContentFrameBody = () => {
    // get the document
    return getContentFrameDocument()
      .its("body")
      .should("not.be.undefined")
      .then(cy.wrap);
     };

    getContentFrameBody()
    getContentFrameBody().find('form[name="mensForm"]');

So that getContentFrameBody() yields a successful assertion yet when I try and chain off it to access elements within the frame:

  getContentFrameBody().find('form[name="mensForm"]');

I get a timeout on the assertion:

Timed out retrying: Expected to find element: form[name="mensForm"], 
but never found it. Queried from element: <body>

I'm wondering I need another command to get inside the #document of frame=content? Could it be related to the onload event?

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.