【发布时间】:2020-11-13 02:52:48
【问题描述】:
在设置和配置 faker 以在 codeceptjs 上工作时确实遇到了麻烦,我查看了他们的网站,但设置不成功。
我只需要在测试用例中提供一个简单的伪造者示例。
我已经通过 npm 'rosie' 和 'faker' 安装了,但没有提到是否需要在 cocept 配置文件中添加任何内容
我只是想为我正在测试的网站生成一个随机的“名字”和“姓氏”,但正如前面所说的那样。
测试示例
var Factory = require('rosie').Factory;
var faker = require('faker');
module.exports = new Factory()
.attr('first name', () => faker.first.name.findName());
Feature('checkout');
Scenario('test something', (I) => {
I.amOnPage(''),
I.wait(5);
I.moveCursorTo('//a[contains(text(),"Products")]');
I.wait(1);
I.moveCursorTo('//a[contains(text(),"Patient Care")]');
I.wait(1);
I.click('//a[contains(text(),"Patient Protectors")]');
//I.wait(2);
I.click('//img[@alt="Blue Disposable Bibs"]');
//I.wait(2);
I.click('Add to basket')
//I.wait(5);
I.click({css:'i.fa.fa-shopping-basket'});
I.wait(5);
I.click('//a[contains(@href, "")]');
I.fillField('First Name', faker.first.name());
I.wait(5); //check to see if this worked
任何帮助将不胜感激,谢谢
【问题讨论】:
标签: codeceptjs faker.js