catchpoint / WebPageTest.agent

Cross-platform WebPageTest agent
Other
213 stars 138 forks source link

Not able to reset executionContext #616

Open manpreet-compro opened 1 year ago

manpreet-compro commented 1 year ago

Use Case: Perform some action in the iframe and then some action on main document

I referred the documentation https://docs.webpagetest.org/scripting/#setexecutioncontext for switching the execution context and followed the example code

Script:

navigate https://codepen.io/juno_okyo/pen/yOjaEZ
setExecutionContext origin=https://cdpn.io
execAndWait document.getElementById('name-input').value = 'Bob';
execAndWait document.querySelector('button').click();
sleep 2
setExecutionContext
clickAndWait data-test-id=login-button
sleep 10

Expected Action:

  1. Set execution context to of iframe
  2. Type Bob in the input field
  3. Click 'OK' button
  4. Set execution context to main document
  5. Click on 'Login' button in the header

Error Faced No action captured after resetting the execution context. Results can be referred from https://www.webpagetest.org/result/230517_AiDcJ3_9W6/

Step 4 is not captured at all and there is no data

pmeenan commented 1 year ago

The in-flight PR should fix the resetting of the execution context. Not sure if it will solve all of the issues (i.e. a sleep 10 after a script step won't cause it to wait 10 seconds for that step to be recorded, it's just a pause before the next step).