【问题标题】:Cypress won't open the specified URLCypress 不会打开指定的 URL
【发布时间】:2023-01-13 04:38:51
【问题描述】:

当我运行测试时,指定的 URL 没有打开,即使它输入正确并在 cypress.config.js 的 BaseUrl 中设置:

> module.exports = defineConfig({   e2e: {
>     "projectId": "fi4fhz",
>     "viewportHeight": 1080,
>     "viewportWidth": 1920,
>     specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
>     baseUrl: 'https://pha.mm.int:6001/',
>    
>        setupNodeEvents(on, config) {
> 
>     },   },

【问题讨论】:

  • 你能在失败的地方包括代码吗?

标签: javascript cypress


【解决方案1】:

根据问题中的信息,我假设您没有包含 a cy.visit() command. 没有该命令,赛普拉斯不知道打开网页。

【讨论】:

    【解决方案2】:

    baseUrl 值 https://pha.mm.int:6001/ 显示在浏览器地址栏中,因为 Cypress 使用它来配置运行器。

    但是包含被测网页的 <iframe> 在您执行之前不会更改
    第一个cy.visit('/')。

    这是为了允许您在页面加载发生之前执行代码,例如 cy.intercept() 和 cy.fixture()。

    【讨论】:

      猜你喜欢
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      相关资源
      最近更新 更多