diff --git a/packages/auth/src/auth-keycloak.js b/packages/auth/src/auth-keycloak.js
index 1f3397116c1381efd5d04957129b18119c6ca358..7a3f408b3d4f65e1596e6fa48f0edfb7edb9a50a 100644
--- a/packages/auth/src/auth-keycloak.js
+++ b/packages/auth/src/auth-keycloak.js
@@ -171,14 +171,14 @@ export class AuthKeycloak extends AdapterLitElement {
             person: this._user,
         };
 
-        this.setAttribute("data-auth-set", "true");
-
         // inject a window.DBPAuth variable for Cypress/Playwright
         if (window.Cypress || window.playwright) {
             window.DBPAuth = auth;
             console.log("Cypress/Playwright detected");
         }
 
+        this.setAttribute("data-auth-set", "true");
+
         this.sendSetPropertyEvent('auth', auth);
     }