Inconsistent assert behavior for text
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, node.js
- 领域
- testing-qa
调研方向
先使用 examples/returns.html 和 examples/bootstrap.html 运行提供的场景,然后将 I.see、I.waitForText 和 I.grabTextFrom 与 #app 和 #app.at(1) 进行比较。跟踪每个 assertion 从何处获取文本,以及如何对其进行规范化。当这些方法、选择器、空白和样式场景中的预期文本行为都已定义且保持一致时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Hello!
While experimenting with codecept I noticed inconsistent behaviors between the testing methods.
Here are two tests:
- The first contains spans that have numbers in them. The asserts are generally consistent (they add spaces to each span) except grabTextFrom, which adds \n.
- The second is much more problematic. In this one, the HTML also contains spans, but with bootstrap styles on the spans. We can see that:
- I.see adds spaces
- I.waitForText does not
- nor does I.grabTextFrom
- BUT when we add .at(1) to the locator, it changes the behavior of waitForText().
The way the text is asserted changes depending on:
- the CSS of the page
- the assertion method used
- the selector
- the whitespaces in the HTML
import { writeFileSync } from "node:fs";
import { resolve } from "node:path";
Feature("Spans");
Scenario("text line returns", async ({ I }) => {
const file = `${resolve(process.cwd(), "examples", "returns.html")}`;
writeFileSync(file, `
<div id="app">
<span>1</span>
<span>2</span>
<span>3</span>
</div>
`);
I.amOnPage(`file://${file}`);
const appLocator = locate("#app");
I.see("1 2 3", appLocator);
I.waitForText("1 2 3", 1, appLocator);
const text = await I.grabTextFrom(appLocator);
I.expect(text).toEqual("\n 1\n 2\n 3\n ");
I.see("1 2 3", appLocator.at(1));
I.waitForText("1 2 3", 1, appLocator.at(1));
const text2 = await I.grabTextFrom(appLocator.at(1));
I.expect(text2).toEqual("\n 1\n 2\n 3\n ");
});
Scenario("test boostrap styles", async ({ I }) => {
const file = `${resolve(process.cwd(), "examples", "bootstrap.html")}`;
writeFileSync(file, `
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<div class="d-flex align-items-baseline lh-1 monospace-numbers" id="app"><span class="text-nowrap fs-21 lh-1">0</span><span class="text-nowrap fs-21 lh-1">.</span><span class="text-nowrap fs-21 lh-1">8</span><span class="text-nowrap fs-21 lh-1">8</span><span class="text-nowrap fs-48 lh-1">6</span><span class="text-nowrap fs-48 lh-1">7</span><span class="text-nowrap fs-18 lh-1 align-self-start mt-1">8</span></div>
`);
I.amOnPage(`file://${file}`);
const appLocator = locate("#app");
I.see("0 . 8 8 6 7 8", appLocator);
I.waitForText("0.88678", 1, appLocator);
const text = await I.grabTextFrom(appLocator);
I.expect(text).toEqual("0.88678");
I.see("0 . 8 8 6 7 8", appLocator.at(1));
// IDK what it expects... it just does not work the same with .at(1)!!!!
// I.waitForText("0.88678", 1, appLocator.at(1));
const text2 = await I.grabTextFrom(appLocator.at(1));
I.expect(text2).toEqual("0.88678");
});
- 主要语言
- JavaScript
- 星标
- 4.2k
- 派生
- 756
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 16
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codeceptjs/CodeceptJS 的其他 Issue
-
stale
难度 2/5 1-3 小时 新手友好度 72/100
codeceptjs/CodeceptJS#5420 · 1 条评论 ·
-
stale
难度 2/5 1-3 小时 新手友好度 76/100
codeceptjs/CodeceptJS#5358 · 1 条评论 ·
-
stale
难度 2/5 1-3 小时 新手友好度 78/100
codeceptjs/CodeceptJS#4958 · 10 条评论 · 2 个 reaction ·
-
stale
难度 1/5 1 小时以内 新手友好度 72/100
codeceptjs/CodeceptJS#4778 · 3 条评论 ·
-
stale
难度 4/5 3-5 天 新手友好度 38/100
codeceptjs/CodeceptJS#5618 · 1 条评论 ·
查看 codeceptjs/CodeceptJS 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
palladius/rails8-app-on-gcp#145 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
dotenvx/dotenv-vscode#139 ·
-
test-change-proposal
难度 2/5 1-3 小时 新手友好度 65/100
web-platform-tests/interop#1455 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
corsairdev/corsair#1764 ·
-
难度 2/5 1-3 小时 新手友好度 75/100