【发布时间】:2021-02-02 21:16:42
【问题描述】:
我目前正在设置一个允许我创建随机电子邮件的测试场景,我想做更多系列的测试并继续在同一个 JSON 文件上写入,而不是覆盖我已经发送到 JSON 文件的内容.这意味着我想使用同一个 JSON 文件来保存我在测试中创建的所有电子邮件。
有人知道更好的方法吗?
Cypress.Commands.add("form", ()=> {
// fill-out form
function makeid(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
const fullName = 'MockaData Testing'
const email = makeid(6) + "@aharo.com";
console.log(makeid(5));
cy.get('#full_name')
.type(fullName)
cy.get('#company')
.type('Testing')
cy.get('#phone_number')
.type('2022569878')
cy.get('#email')
.type(email).writeFile('cypress/fixtures/users.json', {name: fullName, email: email})
cy.get('#password')
.type('Abcd1234')
// click submit
cy.get(".app-submit-btn-text", { multiple: true }).click()
})
【问题讨论】:
标签: testing automation cypress qa cypress-cucumber-preprocessor