cloudlog/cypress/support/commands.js
Peter Goodhall 05a6e6692c Improve logbook tests and use env credentials in Cypress
Enhanced Cypress logbook tests for reliability by adding waits for login and page load, and improved assertions for table and button presence. Updated login command to use environment variables for credentials, allowing more flexible test configuration.
2025-11-26 13:08:53 +00:00

15 lines
672 B
JavaScript

Cypress.Commands.add("login", () => {
// Use environment variables or change these to your actual test credentials
const username = Cypress.env('username') || "m0abc";
const password = Cypress.env('password') || "demo";
cy.visit("/index.php/user/login");
cy.get('input[name="user_name"]').type(username);
cy.get('input[name="user_password"]').type(password);
cy.get('button[type="submit"]').click();
});
// Custom command to wait for select elements to be populated
Cypress.Commands.add("waitForSelectOptions", (selector, minOptions = 1) => {
cy.get(selector).should('be.visible');
cy.get(`${selector} option`).should('have.length.greaterThan', minOptions);
});