1

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?

Fody
  • 23,754
  • 3
  • 20
  • 37
D0nKEYKon9
  • 47
  • 4

1 Answers1

2

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)
});
  
Fody
  • 23,754
  • 3
  • 20
  • 37