【问题标题】:Setting up and configuring Faker Js for CodeceptJs为 CodeceptJs 设置和配置 Faker Js
【发布时间】: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


    【解决方案1】:

    将生成名字的伪造库位于“name”下。您目前拥有faker.first.name.findName()。请参阅 Codecept.js 和下面的 faker 示例:

        var faker = require('faker');
        
        Feature('Test using faker');
        
        Scenario('Verify that a user is able to add first name to first name field',({ I }) => {
            patientfname = faker.name.firstName()
            I.click('#firstnamefieldid')
            I.fillField('#firstnamefieldid', patientfname)
        });
    

    【讨论】:

      猜你喜欢
      • 2023-01-14
      • 2020-02-21
      • 2021-03-06
      • 1970-01-01
      • 2014-08-05
      • 1970-01-01
      • 1970-01-01
      • 2017-10-03
      • 2017-02-27
      相关资源
      最近更新 更多