网站搜索

typescript - Cypress+TS,如何获取被双引号包裹的第二个文本?

我得到了这个网页来测试索赔编号。但我无法提取它。

<h1 class="jss41 undefined" style="text-transform: capitalize; display: flex; align-items: center; margin-bottom: 0.5rem;"> "Claims #" "75078" </h1>

我正在尝试获取的 xpath 是

export c

阅读更多 →

javascript - 我如何在 Remix 项目的 Cypress 测试中访问 app.state

Cypress 有一种方法可以将应用程序的状态暴露给测试运行器——在 React 中通常看起来像这样:

class MyComponent extends React.Component { constructor (props) { super(props) // only expose the app during E2E tests if (window.Cypress) { window.app = this } } ... }

然后你可以在

阅读更多 →

typescript - 我的 Angular tsconfig 无法检测到我的 Cypress 类型

我的 Angular tsconfig 无法检测到我的 Cypress 12.3 类型。我尝试了各种方法来解决这个问题,除了重新开始我的 Cypress 项目(我怀疑那样会有效)。

我的代码运行良好,但我无法在我的 IDE 中解决这里显示的情况:

目前,我的 cypress/tsconfig.json 看起来是这样的:

{ "extends": "../tsconfig.spec.json", "files": [ "../cypress/**/*

阅读更多 →

typescript - 在 cy.origin 中使用 Cypress.require

我正在尝试使用随 12.6.0 发布的 Cypress.require,以便能够在 cy.origin 回调中导入外部依赖项。

根据文档,这应该可以用于任何 TypeScript 模块:https://docs.cypress.io/api/cypress-api/require

这是我尝试的:

// test.js module.exports = { foo: 'bar', }; // test.cy.ts describe('Some test', (): void => { it('should work', (): void => { cy.origin('https://example.com', (): void => { const test = Cypress.require('./test.js'); cy.log('test', test); }); })

阅读更多 →

javascript - Cypress - 安装 'del' 模块时出现错误,无法打开 Cypress

我安装了 del 模块:https://docs.cypress.io/api/plugins/after-spec-api#Delete-the-recorded-video-if-the-spec-passed

然后我配置了 Cypress 配置,但是这一行:

const del = require('del')

导致 Cypress 无法工作(我甚至无法选择任何浏览器):

阅读更多 →

我如何使用 TypeScript 为 Cypress 设置自定义命令?

我使用 yarn 启动了一个新项目,并添加了 TypeScript 和 cypress 作为依赖项。我创建了一个带有自定义命令的示例测试。测试位于文件 cypress/e2e/cypress/example.cy.ts 中,其内容如下:

describe('Example', () => { it('example', () => { cy.myCommand(); }) })

该命令位于 cypress/e

阅读更多 →

typescript - Cypress:如何从自定义命令返回布尔值?

我正在尝试编写一个自定义命令,该命令将接受元素选择器作为参数,并返回一个布尔值,指示该元素是否存在。但自定义命令显示如下内容:

Type 'boolean' is not assignable to type 'CanReturnChainable'

这是我自定义命令的代码。

declare global { namespace Cypress { interface Chainable<Subject> { isPresent(elementSelector: s

阅读更多 →

javascript - 使用 cy.exec() 在 Cypress 中更改目录

使用 Cypress 运行不同文件夹的 Python 脚本。但我猜目录没有完全改变。

gotoPythonProject() { cy.exec("cd /Users/**/Desktop/project/"); cy.exec("ls"); // which does not reflect the files of project that's been changed cy.reload(); }

答案#1

像许多持续集成工具一样,每个命令在一个新的作用域中开始是正常行为

阅读更多 →

javascript - 在 Cypress 中加载时继续向下滚动

我有一个页面,其中有一个元素,当你向下滚动时,它会加载新数据。

这大约需要10秒。

我已经写了以下测试:

it('Should display at least one facility in booking panel', (done) => { function recursivelyScroll() { cy.get(element) .scrollTo('bottom'); cy.get(element) .then($el => { // If the element contains a loading c

阅读更多 →