Synthetic monitor lying about successfull test

I’ve written a script for a synthetic monitor that simulates a client buying a subscription to a media website. For this, the client has to log in, go to the subscription store, click on a subscription and fill in the credit card data. I run the test and it says it has been successfull, but I know it’s lying because I don’t get any more logs past a certain step.

We’re reusing code in our monitors, so we define functions for everything. This is the main script:

(async () => {
  try {
    await getMainLoginFlow();
    console.log(`After getMainLoginFlow: ${timeEllapsed()}s`);
    await getMainSubscriptionFlow();
    await $browser.takeScreenshot();
    await fillCreditCardFormFlow();
  } catch (error) {
    throw new Error(error);
  }
})();

The script is getting stuck right into the function getMainSubscriptionFlow. The first thing it does is look for a button:

const getMainSubscriptionFlow = async () => {
  console.log('getMainSubscriptionFlow');
  try {
    await waitSuscriptionButton();
    console.log('The suscription button has found');

And the code to search for the button is (used to be) very simple. I’ve changed it to try and debug the problem, but I just can’t find it:

const waitSuscriptionButton = async () => {
  console.log('waitSuscriptionButton');
  try {
    await $browser.wait(
      $driver.until.elementLocated($driver.By.className('button-subscribe')),
      60000
    );
  } catch (error) {
    throw new Error(`Error while waiting for subscription button: ${error}`);
  }
  console.log('after waitSuscriptionButton', timeEllapsed());
};

That 60000 timeout started as a 3 second timeout and grew because I was getting a timeout error. At this point, the 60 second timeout never triggers, so I get no error, but I know the execution isn’t going forward because these are the logs I can see when I run the monitor:
image

It never gets past that initial console.log() inside the function. I added the try-catch block just to be even safer, but I don’t get any errors. It’s just like the script didn’t continue running. What’s going on? Any clues?

Hi, @dhernandez1: One issue may be that (link):

Screen Shot 2021-04-05

You might try rewriting your monitor to use the supported Promise syntax (nested .then() functions) and see if it works correctly.

@philweber That’s odd… I thought it was supported in 0.6.x, specially because I don’t see any “Unexpected token async” when I run this script. I would expect that kind of error if async-await was not supported.

1 Like