Changes in the login page break our integration test

There seems to be some changes on the Confluence login page. We used to be able to simulate log in (in our integration test) with Puppet script:

  const username = process.env.ZENUML_STAGE_USERNAME;
  await page.$eval('input[name=username]', (el, value) => el.value = value, username);

  const password = process.env.ZENUML_STAGE_PASSWORD;
  if(!password) {
    throw 'Error: Missing password';
  await page.$eval('input[name=password]', (el, value) => el.value = value, password);
  await page.waitForXPath('//span[text() = "Log in"]');

It has stopped working recently (from 22nd Aug 2023). We managed to fixed it with a combination of keyboard.type and waitForTimeout.
We are wondering if the community or Atlassian has any better recommendations for addressing this issue. Thank you!