赛普拉斯:如何从Mailosaur上创建的虚拟设备检索一次性密码

发布于 2025-02-11 10:53:41 字数 797 浏览 2 评论 0原文

我在Mailosaur上设置了一个虚拟设备,如下所示。

在此图像中,您可以看到“显示一次性密码”按钮。

我已经检查了密码是否可以与我正在使用的网站一起使用,现在我正在尝试创建一个柏树测试以检索该密码,并将其键入文本字段。

我目前在柏树中有的代码。Feature文件看起来像这样。

我当前在cypress.js文件中的代码如下。

我不确定“ MailosaurgetDeviceOTP”功能是否可以执行我要做的事情。请注意,“ deviceName”是第一个图像中的名称。

如何从Mailosaur上的虚拟设备中获取一次密码,然后将其键入用于使用的文本框?

I have a virtual device set up on Mailosaur, as seen below.
Mailosaur Virtual Device

Within this image, you can see the "Reveal One-Time Passcode" button.

I have checked that the passcode works with the website I am working with, and now I am trying to create a Cypress test to retrieve this passcode, and type it into a text field.

The code I currently have in the Cypress.feature file looks like this.
CypressExample.feature

The code I currently have in the Cypress.js file looks like this.
CypressExample.js

I am unsure if the "mailosaurGetDeviceOtp" function does what I am trying to do. Note that 'deviceName' is the same name that is in the first image, mailosaurINT.

How do I get the one time passcode from the virtual device on Mailosaur, and then type it into a text box to be used?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺孤伤于心 2025-02-18 10:53:41

cypress-mailosaur中有一个测试,该测试说明了如何使用自定义命令,

ref

it('.mailosaurGetDeviceOtp should retrieve an otp via device ID', (done) => {
  cy.mailosaurGetDeviceOtp(createdDevice.id).then((otpResult) => {
    expect(otpResult.code).to.be.a('string');
    expect(otpResult.code).to.have.lengthOf(6);
    done();
  });
});

所以您的测试就是这样(我不认为douond()呼叫这里需要)

cy.mailosaurGetDeviceOtp(Cypress.env('deviceName')).then((otpResult) => {
  cy.get(`input[placeholder="${placeholderText}"]`)
    .type(otpResult)
});
  

There's a test in cypress-mailosaur that illustrates how to use the custom command,

Ref

it('.mailosaurGetDeviceOtp should retrieve an otp via device ID', (done) => {
  cy.mailosaurGetDeviceOtp(createdDevice.id).then((otpResult) => {
    expect(otpResult.code).to.be.a('string');
    expect(otpResult.code).to.have.lengthOf(6);
    done();
  });
});

so your test would be this (I don't think the done() call is needed here)

cy.mailosaurGetDeviceOtp(Cypress.env('deviceName')).then((otpResult) => {
  cy.get(`input[placeholder="${placeholderText}"]`)
    .type(otpResult)
});
  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文