title: Puppeteer - invoke external JS function from a 5th level deep child page in frameset
body: <p>I am trying to achieve puppeteer automation on a 20 year old e-commerce site which is built on apache Struts framework. I cannot replicate the entire struts action servlets, however I have simulated the HTML pages that get loads 14 different pages in frames once the person logs in and selects the Shop.
  The goal is to click the Create New Shopping Basket from one of the 14 pages that are loaded in the 5th deep child frame page. That link calls an external javascript function, but the puppeteer returns this error:</p>
  <pre><code>Error: Evaluation failed: ReferenceError: create_order is not defined
      at __puppeteer_evaluation_script__:1:8
      at ExecutionContext._evaluateInternal (&lt;path&gt;/headless-chrome/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:221:19)
      at async ExecutionContext.evaluate (&lt;path&gt;/headless-chrome/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:110:16)
      at async Promise.all (index 1)
      at async &lt;path&gt;/headless-chrome/simulation/index.js:40:5
  </code></pre>
  <p>Here is the link to all html files, the external javascript file and the puppeteer js file.
  <a href="https://github.com/samgajjar/headless-chrome" rel="nofollow noreferrer">https://github.com/samgajjar/headless-chrome</a></p>
  <p>Extract all zip file and here is how to navigate manually</p>
  <ul>
  <li>Open Login.html</li>
  <li>Can enter any username / password and click the Login Button</li>
  <li>This will show list of Shops</li>
  <li>Select Shop ISA_2120_EN</li>
  <li>This will open the frameset that loads 14 files
  and from here the script should click Create New Shopping Basket that call a js function - create_order() which is inside make_new_doc.js file</li>
  </ul>
  <p>The puppeteer index.js does execute the login and selection of the shop but error on creating the basket with above error</p>
  <p>Thanks!!</p>