Cypress -> 您的测试正在加载

问题描述 投票:0回答:1

我遇到了问题,我尝试解决它,但我不明白为什么它不起作用。我进行了测试,但测试从未完成。我收到“您的测试正在加载...”,但它也没有选择该按钮。我附上我在这里的信息:

 '''describe('Salesforce Login', () => {
      it('should login to Salesforce', () => {
        // Visit the Salesforce login page
        console.log('Clicked on Login button');
        cy.visit('');
     
        // Fill in the username and password
        cy.get('#username').type('');
        cy.get('#password').type('');
     
        cy.get('#Login').click();

          cy.wait(10000);
      
          cy.get('button.slds-button[title="Show Navigation Menu"]').click();

          console.log('Clicked on element after login');

         
       
    })});'''

以及以下内容: 索引.js

import './commands';
require('cypress-xpath');

Cypress.on('uncaught:exception', (err, runnable) => {
  // Check for the specific error message
  if (err.message.includes('Cannot read properties of undefined (reading \'addEventHandler\')')) {
    // Prevent Cypress from failing the test
    return false;
  }
  // Let other errors fail the test
  return true;
}); 

以及以下内容: 赛普拉斯.config.js: '''

const { defineConfig } = require('vite');
const react = require('@vitejs/plugin-react');

module.exports = defineConfig({
  e2e: {
    // Enable experimental studio mode for Cypress
    experimentalStudio: true,
    // Specify the path to the Cypress support file
    supportFile: 'cypress/support/index.js',
  },
  // Set the viewport dimensions for the tests
  viewportHeight: 768,
  viewportWidth: 1366,
  component: {
    devServer: {
      // Specify the framework being used
      framework: "react",
      // Specify the bundler being used
      bundler: "vite",
      viteConfig: {
        // Add the React plugin for Vite
        plugins: [react()],
        server: {
          // Set the development server port
          port: 3000,
        },
        // Disable Chrome web security for tests (use with caution)
        chromeWebSecurity: false,
      },
    },
  },
});
'''
cypress
1个回答
0
投票

你的 cy.visit() 必须填写一个网址,除此之外我看不出有什么问题

cy.visit('https://www.yoursite.com')
© www.soinside.com 2019 - 2024. All rights reserved.