Cloudlog/cypress/support/commands.js
copilot-swe-agent[bot] ae47a5204a Fix contest logging locator field length and tab navigation issues
Co-authored-by: magicbug <84308+magicbug@users.noreply.github.com>
2025-07-30 15:36:19 +00:00

20 行
761 B
JavaScript

Cypress.Commands.add("login", () => {
const username = "m0abc";
const 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);
});
// Custom command to simulate tab key press
Cypress.Commands.add("tab", { prevSubject: 'element' }, (subject) => {
cy.wrap(subject).trigger('keydown', { key: 'Tab', code: 'Tab', keyCode: 9 });
return cy.focused();
});