`I.waitForURL()` does not fail the test when its timeout happens

未关闭
#4,346 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
32/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
playwright, typescript
领域
testing-qa

调研方向

使用 heal.ts 中的 healer 重现 playground.ts 中的场景,然后跟踪 Playwright Helper 中的 I.waitForURL 入口点以及其超时的报告方式。完成的标准是:超时导致场景失败,阻止后续点击和 healer 运行,并保留相关的失败输出。

由索引模型根据 Issue 内容生成。

描述

stale
What are you trying to achieve?

Wait for the page to navigate to a certain URL and fail the test if it doesn't navigate within the defined timeout

What do you get instead?

The test does not fail. As per the source code, we should never get to I.click("#fake-id");, but we do. Also, In the below source code, the log after I.waitForURL() is never printed. Where does it disappear to? The log that's printed is the one that's within the healer, HEALING A FAILED CLICK STEP:#fake-id.

Provide test source code if related

# Playground.feature

Feature: Play around
  Scenario: Playground
    Given I want to test healers
// playground.ts

Given("I want to test healers", () => {
  I.amOnPage("https://github.com/codeceptjs/CodeceptJS/issues");
  I.say("before waitForURL");
  I.waitForURL("https://fake-url", {
    timeout: 10000,
    waitUntil: "load"
  });

  I.say("after waitForURL");
  I.click("#fake-id");
});
// heal.ts

const { heal, ai } = require("codeceptjs");

heal.addRecipe("waitForVisibleThenClick", {
  priority: 1,
  steps: [
    "click"
  ],
  fn: async ({ step }) => {
    const locator = step.args[0];

    return ({ I }) => {
      I.say("HEALING A FAILED CLICK STEP:" + locator);

      I.waitForVisible(locator, 9);
      I.click(locator);
    };
  },
});

This is what is displayed on the logs after the test run:

Play around --
  Playground
   Given I want to test healers ""
   before waitForURL <--------------------------------------------- see here
    I say "HEALING A FAILED CLICK STEP:#fake-id" <----------------- and here
   HEALING A FAILED CLICK STEP:#fake-id  <------------------------- and here
    I wait for visible "#fake-id", 9
  × FAILED in 29095ms


-- FAILURES:

  1) Play around
       Playground:
     element (#fake-id) still not visible after 9 sec
locator.waitFor: Timeout 9000ms exceeded.
Call log:
  - waiting for locator('#fake-id').first() to be visible

  Error: element (#fake-id) still not visible after 9 sec
  locator.waitFor: Timeout 9000ms exceeded.
  Call log:

  Scenario Steps:
  - I.waitForURL("https://fake-url", {"timeout":10000,"waitUntil":"load"}) at .\tests\steps\playground.ts:21:5
  - I.say("before waitForURL") at .\tests\steps\playground.ts:20:5
  - I.amOnPage("https://github.com/codeceptjs/CodeceptJS/issues") at .\tests\steps\playground.ts:19:5

Details
  • CodeceptJS version: 3.6.2
  • NodeJS Version: 20.12.2
  • Operating System: Windows 11
  • Helper: Playwright Helper
  • Configuration file:
require('./heal')

export const config: CodeceptJS.MainConfig = {
  output: './output',
  helpers: {
    Playwright: {
      url: "https://github.com/codeceptjs/CodeceptJS/issues",
      show: false,
      browser: 'chromium'
    }
  },
  gherkin: {
    features: ["./tests/**/features/Playground.feature"],
    steps: "./tests/**/steps/*.ts"
    // steps: ["./stock_take_service/steps/given.ts", "./stock_take_service/steps/when.ts", "./stock_take_service/steps/then.ts"]
  },
  include: {
    I: './steps_file',
  },
  plugins: {
    heal: {
      enabled: true
    }
  },
  name: 'playground'
}

主要语言
JavaScript
星标
4.2k
派生
756
平均合并
2 天 9 小时
30 天内合并 PR
16

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

codeceptjs/CodeceptJS 的其他 Issue

查看 codeceptjs/CodeceptJS 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。