我在这里做了一个简单的测试,但是我看到很多人都遇到了这个问题,但不幸的是,我无法找到解决方案,所以,因此,我要求你的意见。\n现在,我在链接内有这个字符串对象:
\n\n...\n<div class="price">12,45 \xe2\x82\xac</div>\n...\nRun Code Online (Sandbox Code Playgroud)\n\n我创建了这个小测试来检查字符串值:
\n\nimport { t, Selector } from \'testcafe\';\nfixture `OfferPage`.page `https://www.verivox.de/applications/broadband/#/offer?i=eyJmaWx0ZXIiOltudWxsLDE2MDAwLDEsbnVsbCwiMDIyMSIsMSwxLDEsbnVsbCwxLDEsbnVsbCwtMSxudWxsLG51bGwsInByaWNlLWFzYyIsMixudWxsLG51bGwsbnVsbCxudWxsLG51bGwsbnVsbCxudWxsLG51bGwsNl0sImRpYWxvZyI6W251bGxdLCJvZmZlckNyaXRlcmlhIjpbIjYxMzQ0NyIsIjE4MjkyIixudWxsLCIyNCIsMywyLCI1MDAwMCIsIjEwMDAwIixudWxsLG51bGwsMSxudWxsLG51bGwsbnVsbCwiMiIsMSxudWxsLCIwMjIxIixudWxsLG51bGwsbnVsbCxudWxsLG51bGwsMSw2LG51bGwsbnVsbCxudWxsXX0%3D`;\ntest(\'1\', async () => {\n const string = Selector(\'div.price\');\n await t.expect(string.innerText).eql(\'12,45 \xe2\x82\xac\');\n});\nRun Code Online (Sandbox Code Playgroud)\n\n我在终端中收到的错误是这样的:
\n\nAssertionError: expected \'12,45 \xe2\x82\xac\' to deeply equal \'12,45 \xe2\x82\xac\'\nRun Code Online (Sandbox Code Playgroud)\n\n我确实试图找到解决方案,但要么我正在更改定义const并let尝试应用其他方法,最终都会出现失败错误,并显示不同的错误消息。\n那么,我该如何解决问题,在上述情况下?\n谢谢!
编辑:感谢您的提示!我编辑了这篇文章,因为我意识到我没有提到我已经尝试过你的建议......
\n\nlet price = Selector(\'div\').withAttribute(\'class\', \'price\');\nconst result = price.parent(\'div.centered-content effective-price-wrapper\');\nconsole.log(result);\nawait t.expect(result.innerText).eql(\'12,45 \xe2\x82\xac\');\nRun Code Online (Sandbox Code Playgroud)\n\n呃:
\n\nCannot obtain information about the node because the specified selector does not match any node in the …Run Code Online (Sandbox Code Playgroud) 我有一套使用 TestCafe 运行的测试。在一个组件中,我需要根据应用程序是否在 testcafe 中运行来了解是否向窗口公开一些数据,即
if (window.Testcafe === true) {
window.property = data;
}
Run Code Online (Sandbox Code Playgroud)
这可以通过另一个测试框架 Cypress 来实现,它公开了 window.Cypress。我尝试在 testcafe 测试/装置中设置窗口属性,使用代码达到以下效果
test('Test 1', async t => {
await t.eval(() => {window.Testcafe = true});
const val = await t.eval(() => window.Testcafe);
// val === true
})
// In component window.Testcafe is false
Run Code Online (Sandbox Code Playgroud)
我对其他方法持开放态度(除了窗口属性)。还有其他人做过类似的事情吗?
我目前正在尝试在赛普拉斯测试时找到鼠标的位置。我正在尝试使用 WebGL 模型,因为我无法单独抓取这些模型并移动它们,所以我正在考虑使用页面坐标/鼠标位置,以便它足够接近。
我在 Cypress 的 github 上发现了一个关于此问题的已关闭问题,但它无法安装,因此如果你们中有人知道为什么它会抛出附加错误,或者有更简单的方法来找出位置,请告诉我!我们将不胜感激。
(抱歉,钢笔标记不好;试图写下我的姓氏)
我运行了已关闭问题中给出的代码:
npm i -D cypress-mouse-position
然后将它们添加到两个文件中:
cypress/plugins/index.js
module.exports = (on, config) => {
# ...
initCypressMousePositionPlugin(on);
# ...
}
Run Code Online (Sandbox Code Playgroud)
cypress/support/index.js
import 'cypress-mouse-position/commands';
Run Code Online (Sandbox Code Playgroud) 这是我的柏树代码:
cy.get(`${sitestovisit.searchBoxFormID} > form`)
.should('have.attr', 'target')<br>
.invoke('removeAttr', 'target')
Run Code Online (Sandbox Code Playgroud)
sitestovisit.searchBoxFormId包含来自 JSON 的数据且其工作正常,但它显示表单中有一个目标属性,但当我尝试删除它时,它不起作用。
当我将上面的代码替换为:
cy.get('#booking_search > form')
.invoke('removeAttr', 'target')
Run Code Online (Sandbox Code Playgroud)
它工作正常,有什么问题吗?我不能直接使用,因为我需要循环使用它 这是输出
我的团队使用内部 e2e 测试框架来测试从 http 请求到 http 响应的所有内容是否按预期工作。
由于 AWS 中跨多个地理位置的分布式架构的性质,这些测试的工作方式非常复杂且不稳定。
我们遇到的一个大问题是,当我们将功能 PR 合并到影响端点响应/行为的众多微服务/lambda 之一时,我们的 e2e 测试会失败。
我们处理这个问题的方法是接受 e2e Jenkins 作业将暂时变为红色,直到有人获得更新/添加测试的 e2e PR 合并。
由于接受 e2e 作业“暂时”呈红色,因此会导致其他可能包含或不包含 bug 的更改。
另一个问题是,如果构建失败(这很好),我们不允许合并 PR,但如果 e2e 测试由于不同服务的更改而失败,则修复 e2e 测试的人员会发现他们的功能正在进行的工作将需要修复同一 PR 中的其他故障。
所以我的问题是,我的团队可以做些什么来解决这个问题?
我希望我们保留 e2e 测试,因为它们非常有用,但由于上述原因,它们很容易被忽视。
我们能否以某种方式将 e2e 测试存储库与每个功能分支联系起来,以便当有人将代码推送到分支时,我们的 e2e 测试服务上具有相同名称的功能分支会针对它运行并阻止 PR,直到他们更新 e2e 测试为止?
任何有关如何使用 github 工作流程对 AWS 中的分布式微服务/lambda 架构进行 e2e 测试的建议/示例将非常感激。
而且,我很难相信我的团队是唯一遇到这个问题的团队。所以也许这会帮助其他人。
我已经在另一个答案中尝试过类似的方法How to type using cypress .type() inside the codemirror editor?
如果有帮助的话,这是我正在 Cypress 上工作的网站https://testing-playground.com/
// CodeMirror's editor doesn't let us clear it from the
// textarea, but we can read the Window object and then
// invoke `setValue` on the editor global
cy.window().then(win => {
win.editor.setValue("")
})
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是,当我尝试实现这个时,我得到了undefined编辑器。我尝试深入研究 Window 对象,但找不到任何类似于 Codemirror 编辑器的内容。.clear({force: true})在任何其他 Codemirror 元素上运行都不会产生任何结果,只会.type({force: true})在文本字段上添加新内容和旧内容。
我看到了一些与我类似的帖子,但我发现它根本没有帮助,因为他们都没有使用 cypress 预处理器。
我有一个场景:
Scenario: Some scenario
Given ...
When ...
Then I should see "<task_field>" field as "<field_value>"
Examples:
| task_field | field_value |
| some_field1 | some_value1 |
| some_field2 | some_value2 |
| some_field3 | some_value3 |
Run Code Online (Sandbox Code Playgroud)
.js 文件具有:
Then('I should see {string} field as {string}', (field, value ) => {
switch (field) {
case 'some_field1':
cy.get('.someClass1').contains(value)
break
case 'some_field2':
cy.get('.someClass2').contains(value)
break
case 'some_field3':
cy.get('.someClass3').contains(value)
break
default:
throw new Error(`Invalid field: ${field}`)
}
})
Run Code Online (Sandbox Code Playgroud)
我的目标是检查每个 some_field 是否等于 …
$ 或 findElement 的 webdriverio 文档不是那么广泛,我习惯了其他 e2e 工具,因此很混乱,要找到一个具有这两个属性的元素,我想实现类似的效果:
const element = $('[title="HOW TO USE?", data-text="HOW TO USE?"]');
Run Code Online (Sandbox Code Playgroud)
这是正确的语法吗?
WEBDRIVERIO 版本:5.6.6
我正在尝试检查从应用程序中的元素获取的一个日期值是否小于今天的日期:
const todaysDate = Cypress.moment().format('DD/MM/YYYY')
it("Check date to be less or equal than todays", () => {
cy.get('.date', { timeout: 15000 }).eq(3).invoke('text').should('be.lte', todaysDate);
})
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
Timed out retrying after 4000ms: expected '12/14/2020' to be a number or a date
Run Code Online (Sandbox Code Playgroud)
有没有办法将从元素获取的日期转换为日期时间对象?
我正在尝试访问谷歌在剧作家中注册的新弹出窗口,但无法做到这一点。
await page.waitForSelector(signUpWithGoogle, { state: 'visible' })
await page.focus(signUpWithGoogle)
await page.click(signUpWithGoogle)
await page.fill('//input[@type="email"]', email)
Run Code Online (Sandbox Code Playgroud) e2e-testing ×10
javascript ×6
cypress ×5
testcafe ×2
assert ×1
codemirror ×1
cucumber ×1
git ×1
github ×1
jenkins ×1
jestjs ×1
playwright ×1
reactjs ×1
testing ×1
typescript ×1
web-testing ×1
webdriver-io ×1