Reputation: 65
really having trouble with setting up and configuring faker to work on codeceptjs, I have had a look at their website but no luck with the set up.
I just need need a simple example of faker within a test case.
I have installed through npm 'rosie' and 'faker', but there was no mention if i need to add anything to the cocept config file
I am just trying to generate a random 'first name' and 'last name for a website that I am testing, but as said earlier stuck on this.
Example of the the test
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
Any help would be appreciated, thanks
Upvotes: 1
Views: 576
Reputation: 11
The faker library that will generate a first name is under "name". You currently have faker.first.name.findName()
. See Codecept.js with faker
example below:
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)
});
Upvotes: 1