Check for loaded scripts on the site

Hello,
Is there an easy way to check and assert if a certain script is loaded on the site?

An example scenario:

  1. User performs a certain action on the site which triggers a script to be loaded or not
  2. Check for the script status according to the user action.

Manually I can check for that in the dev tools browser in the Networks tab, how can I GET those into my test case?

Sample script I want to check:

why to do that?

IMHO, an automated test should check if the end result following a certain action was ok.
to intermediately check if a script was loaded or not, is subject for debugging.
not relevant for the test scope
as a tester, you should not worry what the AUT do under the hood.
just that the AUT do the right thing.
for the rest, rise a bug ticket with the AUT developpers.

Basically, some tracking scripts shouldn’t be loaded if the user doesn’t agree to some cookies when first visiting a website so we want to ensure that this functionality is working as expected each time a new user visits the site, it’s vital for GDPR in the Europ.
That’s why I would like to check that in test scenario.

the only thing i have into my mind now is, use mobproxy to capture the har and parse it

2 Likes

Chrome DevTools Protocol could be an alternative.

2 Likes