0

currently, I'm testing my login page using my own login data and I want to use dummy data as profile login data. Can these enter in my spec.ts file or conf.js file?

And this is my spec.ts file:

it('Navigate to the dashboard', () => {
    page.getEmailLogin().sendKeys('first@gmail.com');
    page.getPasswordLogin().sendKeys('123456');
    page.getSubmitLogin().click();

    const EC = browser.ExpectedConditions;
    browser.wait(EC.urlContains('localhost:49152'), 10000);
    browser.wait(EC.urlIs('http://localhost:49152/'), 10000);
});
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Sanjani Gunathilaka
  • 229
  • 1
  • 3
  • 11

1 Answers1

0

You are looking for using browser.params (check this thread also). Specify this in the config:

params: {
  login: {
    user: 'first@gmail.com',
    password: '123456'
  }
},

And, then you could use these configuration variables in the test:

page.getEmailLogin().sendKeys(browser.params.login.user);
page.getPasswordLogin().sendKeys(browser.params.login.password);
page.getSubmitLogin().click();

And, you could pass these values through the command line parameters as well.


As far as generating fake data for tests, on the nodejs side there are libraries like faker, but you would also need to make sure you generate data in other parts of your application under test, of course. But that's a bigger and broader question which would probably be better asked on SQA.stackexchange.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • Thanks for your answer. but navigate to the next page it still requires valid email and password which stores in the database and i want to enter a fake email address and a password. – Sanjani Gunathilaka Dec 18 '18 at 07:19
  • @SanjaniGunathilaka okay, I've probably misunderstood the question. Are you generally asking about generating fake data for tests or how to parameterize your tests to not hardcode variable parameters inside them? Thanks. – alecxe Dec 18 '18 at 15:30