标签: e2e-testing

Cypress 中的页面对象模式?

我想使用类似于 Selenium 等框架中存在的页面对象模式的工作流程。login.spec.js我想在 my 中使用 my editSettings.spec.js,因为它需要用户登录。

我如何在赛普拉斯中实现这一目标?我可以从一个测试文件导出函数以在另一个测试文件中使用吗?

e2e-testing cypress

2
推荐指数
1
解决办法
4799
查看次数

使用 Testcafe 访问受 OpenVPN 限制的网站

有一个网站只有在我运行 OpenVPN Connect 2.1.3.111 配置文件时才能访问。我需要使用 Testcafe 访问该网站,但到目前为止我还没有找到任何关于将 Testcafe 与 VPN 结合使用的文档。有什么我可能错过的吗?

testing automated-tests openvpn e2e-testing testcafe

2
推荐指数
1
解决办法
230
查看次数

如何存储图像的 src 并将其与 Cypress 中的另一个图像进行比较?

测试目标是确认如果用户上传新图片,上传图片的 'src' 属性会发生变化,这意味着图片已更改。

我尝试使用几种方法,概述如下。

第一种方法

cy.get('.img').then($img => {
      //store the src

      const source = $('img').attr('src');

      /**
       * File drop 2mb jpg
       */
      cy.fixture(Cypress.env("JPG_2MB_ASSET"), "base64").then(fileContent => {
        cy.get(".dropzone").upload(
          {
            fileContent,
            fileName: "sampleimage.jpg",
            mimeType: "image/jpeg"
          },
          { subjectType: "drag-n-drop" }
        );
      });
      cy.wait(16000);

      cy.get('img')
        .attr('src')
        .should($src2 => {
          expect($src2).not.to.eq(source);
        });
Run Code Online (Sandbox Code Playgroud)

第二种方法

      //store the src

      const source = $img.attr('src')

      /**
       * File drop 2mb jpg
       */
      cy.fixture(Cypress.env("JPG_2MB"), "base64").then(fileContent => {
        cy.get(".dropzone").upload(
          {
            fileContent,
            fileName: "sampleimage.jpg",
            mimeType: "image/jpeg"
          },
          { subjectType: "drag-n-drop" }
        ); …
Run Code Online (Sandbox Code Playgroud)

javascript e2e-testing cypress

2
推荐指数
1
解决办法
2447
查看次数

使用 testcafe runner 时的 TestCafe BrowserStack 环境问题

我为 TestCafé 使用了“testcafe-browser.provider-browserstack”插件。我尝试在我的应用程序中使用它,但我总是收到一条消息,提示登录错误。数据是正确的(只是“测试”这篇文章)

const createTestCafe = require('testcafe');
const BrowserStack = require("testcafe-browser-provider-browserstack");

let testcafe         = null;

process.env.BROWSERSTACK_USERNAME="test";
process.env.BROWSERSTACK_PASSWORD="test";


createTestCafe('localhost', 1337, 1338)
    .then(tc => {
        testcafe     = tc;
        const runner = testcafe.createRunner();

        return runner
            .src(['tests/fixture1.js', 'tests/ingo1.js'])
            .browsers('browserstack:Chrome')
            //.browsers(['chrome'])
            .screenshots('allure/screenshots/', true)
            .reporter('allure')
            .run();
    })
    .then(failedCount => {
        console.log('Tests failed: ' + failedCount);
        testcafe.close();
    });
Run Code Online (Sandbox Code Playgroud)

automated-tests web-testing browserstack e2e-testing testcafe

2
推荐指数
1
解决办法
289
查看次数

cy.getBy*** 不是函数

我正在尝试在 Azure 发布管道期间运行 Cypress。我安装了我在本地安装的所有软件包,但是当我运行 Cypress 测试时,出现了几个错误:

TypeError: cy.visit(...).getByText 不是函数

类型错误:cy.getByLabelText 不是函数

类型错误:cy.getByPlaceholderText 不是函数

我已将以下包添加到我的package.jsondevDependencies 部分:

"@testing-library/cypress": "^4.0.4",
"@testing-library/react": "^8.0.4",
"@testing-library/dom": "latest",
Run Code Online (Sandbox Code Playgroud)

知道为什么赛普拉斯会返回这些 TypeErrors 吗?

这是一个笔试的例子:

it("can request to join private team", () => {
  const privateTeamId = "fe1fa897-2e90-4ecb-91f9-0c9bb33ef63a";
  cy.get(`[id=${privateTeamId}]`)
    .click()
    .getByText("Request membership")
    .click()
    .getByText("Membership request sent");
});
Run Code Online (Sandbox Code Playgroud)

e2e-testing cypress

2
推荐指数
2
解决办法
3236
查看次数

有什么方法可以使用 jest-puppeteer 对片状测试进行重试?

我遇到了一个问题,在 Jest 中没有内置的方法来重试脆弱的测试。我正在使用 Jest + TS + Puppeteer。任何人都有同样的问题或可能的解决方案\建议?我试图实现这个 : link ,但没有成功。

jest-retries 对我不起作用,因为我创建了用户并做了很多操作,如果测试失败 - 重试在具有相同 cookie 等的同一个 Chrome 选项卡中重新启动测试。提前致谢!

代码示例:

const it = require('jest-retries');

describe('any tests', () => {

beforeEach(async () => {
    await page.emulate(devices['Galaxy S5']);
    await page.goto(newSearchUrl, { waitUntil: 'networkidle2' });

});

it('dummy test', 2, async () => {
    await userSignup(); // custom wrapper for signup
    await checkGraphqlSuccess('success dumb event');
    const iconHeader = await waitForElementVisible(favoriteBtnHeader);
    await iconHeader.click();
    const number = await waitForElementVisible(number1);
    const getNumber1 = await page.evaluate(obj => { …
Run Code Online (Sandbox Code Playgroud)

automated-tests typescript jestjs e2e-testing puppeteer

2
推荐指数
2
解决办法
3425
查看次数

TestCafe - 如何通过 auth0 登录使用角色

我有一个带有 auth0 登录名的应用程序。我一直无法弄清楚如何t.useRole在这种情况下制作。

幸运的是,这很容易重现。auth0(应用程序)使用相同的进程。它以与我的应用程序完全相同的方式失败。

预期结果
- 用户登录
- 用户进入仪表板
- 用户保持登录状态
- 用户再次进入仪表板(第二次测试)

实际
- 用户登录
- 用户进入仪表板
- 用户不再通过身份验证
- 用户进入登录页面

import { Role, Selector, ClientFunction } from 'testcafe';

const getPageUrl = ClientFunction(() => window.location.href.toString());

const exampleRole: Role = Role('https://auth0.com/auth/login', async t => {
    const userNameInput = Selector('input').withAttribute('name', 'email');
    const passwordInput = Selector('input').withAttribute('name', 'password');
    const loginButton = Selector('button').withAttribute('name', 'submit');

    await t
        .wait(5000)
        .click(userNameInput)
        .typeText(userNameInput, userName)
        .click(passwordInput)
        .typeText(passwordInput, password)
        .click(loginButton);
})

fixture(`SAMPLE`)
    .page('https://manage.auth0.com/dashboard')
    .beforeEach(async t => {
        await …
Run Code Online (Sandbox Code Playgroud)

testing automation automated-tests e2e-testing testcafe

2
推荐指数
1
解决办法
285
查看次数

如何获取选择器的字符串值?

我的意思是当我们像这样初始化 Selector 时:

let stringLocator = 'some element locator'
selector = new Selector(stringLocator)
Run Code Online (Sandbox Code Playgroud)

是否可以像这样获得原始字符串定位器:

selector.locator
Run Code Online (Sandbox Code Playgroud)

PS这个问题是与此相关的一个,我已经找到了一些解决方法哈克获得testcafe错误显示我的XPath定位。

testing automation automated-tests e2e-testing testcafe

2
推荐指数
1
解决办法
163
查看次数

执行基于 maven 的端到端测试并在 Tekton Dashboard 中显示结果

我们的端到端测试基于 maven/CucumberJVM。所有工件均使用 Jenkins 构建并保存在 Artifactory 中。那么 tekton 应该适用于一个(或多个)环境

  • 使用 helm 接管并设置基础设施(pods、ingress、configmaps 等)
  • 在环境上运行 Cucumber-end-to-end-tests
  • 显示结果
  • 成功或失败&清理。

我将如何显示测试运行的结果?在 Tekton 仪表板中?已经有插件了吗?作为测试运行的结果,是否可以显示静态 html 文件?

提前感谢您的任何提示。最好的问候,英戈

dashboard e2e-testing tekton

2
推荐指数
1
解决办法
136
查看次数

Nest.js 测试错误:Nest v8 中不允许使用“extends Logger”指令。请改用“扩展 ConsoleLogger”

这是我遇到的问题:

我在 Nest.js 中使用我的自定义记录器:

export class ReportLogger extends ConsoleLogger {
  verbose(message: string) {
    console.log('?Verbose?Reporting', message);
    super.verbose.apply(this, arguments);
  }

  log(message: string) {
    console.log('?Log?Reporting', message);
    super.log.apply(this, arguments);
  }
}
Run Code Online (Sandbox Code Playgroud)

和log.interceptor.ts文件:

export class LogInterceptor implements NestInterceptor {
  constructor(private reportLogger: ReportLogger) {
    this.reportLogger.setContext('LogInterceptor');
  }

  intercept(context: ExecutionContext, next: CallHandler) {
    const http = context.switchToHttp();
    const request = http.getRequest();

    const now = Date.now();
    return next
      .handle()
      .pipe(
        tap(() =>
          this.reportLogger.log(
            `${request.method} ${request.url} ${Date.now() - now}ms`,
          ),
        ),
      );
  }
}
Run Code Online (Sandbox Code Playgroud)

这是main.ts文件:

async …
Run Code Online (Sandbox Code Playgroud)

testing node.js e2e-testing nestjs

2
推荐指数
1
解决办法
398
查看次数