123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- // import 'cypress';
- import { fileIndex } from '../util';
- class LoginPage {
- visit(options?: { onBeforeLoad?: (win: Window) => void }) {
- // if (options?.onBeforeLoad) {
- // cy.visit(`${fileIndex}#/pages/index/index`, {
- // onBeforeLoad: options.onBeforeLoad
- // });
- // } else {
- // cy.visit(`${fileIndex}#/pages/index/index`);
- // }
- cy.visit(`${fileIndex}#/pages/index/index`, {
- onBeforeLoad(win) {
- win.addEventListener('beforeunload', () => console.trace('beforeunload'));
- win.addEventListener('unload', () => console.trace('unload'));
- // ===== 新增两行:钉时间戳 =====
- // cy.stub(win.Date, 'now').returns(1712345678901);
- // ========================================
- // 保持原透传逻辑
- options?.onBeforeLoad?.(win);
- }
- });
- }
- getUsernameInput() {
- return cy.get('[data-testid="login-username-input"]');
- }
- getPasswordInput() {
- return cy.get('[data-testid="login-password-input"]');
- }
- getSubmitButton() {
- return cy.get('[data-testid="login-submit-button"]');
- }
- login(username: string, password: string) {
- this.getUsernameInput().type(username);
- this.getPasswordInput().type(password);
- this.getSubmitButton().click();
- }
- }
- export default LoginPage;
|