Script not executing or stopping too early

I’m trying to write a script that logs in, and after login clicks on a button. I want to measure the whole process from the start of entering credentials, to the end of navigation to the second page after logging in. This is my script below. I’m using a private instance so can’t post the result, but I explain below the 2 different results that I get:

//login
logData 0
navigate https://e2e.qbo.intuit.com
logData 1
execAndWait $(‘#ius-userid’).val(‘###’); $(‘#ius-password’).val(‘###’); $(‘#ius-sign-in-submit-btn’).click();
setDOMElement stepid=step1
execAndWait document.querySelector(‘ha-flow-step[stepid=“step0”] .ha-button-primary’).click();

= data i scrubbed

There’s 2 problems:
1 - If I run the script as is above, it doesn’t complete the click of the button (the last line). It just sits on the page that loads after login.
2 - I also want to measure just the 2nd page loading, ignoring everything before it (in a separate script) and if I try this by moving the logData 1 down to the line above setDOMElement I get error “First View: Test Data Missing” with no results to look at.

Any tips on what I may be doing wrong?

To ask the really dumb question…

Does this line work when you try it in DevTools?

document.querySelector('ha-flow-step[stepid="step0"] .ha-button-primary').click();

Also if you capture the response bodies, is that element in there (I came across a problem with another site where the WPT agent was getting a slightly different page to the one I tested against in my browser)

No idea on #2, I’ve not seen that happen before - might test it with one of my scripts

Thanks for taking a look :slight_smile: Yes it does work in dev tools. It doesn’t seem to be a problem with the script itself, I think it’s a bug with webpagetest to do with the order of using exec or execAndWait. I spent all afternoon Friday trying to figure out what the problem is and will try write up a new post that clearly spells it out.
[hr]
Hm, I can’t seem to get the bug down exactly. Here is what I have written down. Would be great if someone could take a look and comment on why this behaviour is happening:

Succeeded, completed all steps.

logData 0
navigate http://www.yahoo.com
logData 1
setValue id=uh-search-box apple
navigate http://www.google.com

Failed, stopped after navigating to yahoo.com
WebPageTest Test - Running web page performance and optimization tests...
logData 0
navigate http://www.yahoo.com
logData 1
execAndWait document.querySelector(‘#uh-search-box’).value='apple’;
navigate http://www.google.com

Partially succeeded, failed to enter ‘apple’

logData 0
navigate http://www.yahoo.com
logData 1
exec document.querySelector(‘#uh-search-box’).value='apple’;
navigate http://www.google.com