How can i use the data driven or dynamic username and password when i enter the actor name in the cucumber it should use the respective password maybe from a json file or something depending on the actor.
So when i enter this in the feature file
//example.feature
Feature: Add item and place the order for that item
In order to wear something new
As an online shopping customer
I want to be able to add an item to my shopping bag and then place the order
Scenario: Add an item to shopping bag to place the order using Paypal
Given that "Bruno" is logged in to his "admin" account
When he searches and adds an item from "men" section to his shopping bag
Then he can place the order
// example.steps.ts
import { Actor } from "serenity-js/lib/screenplay";
import { BrowseTheWeb } from "serenity-js/lib/screenplay-protractor";
import { protractor } from "protractor";
import { Start, AddItemsToShoppingBag } from "../website-model/src/index";
import { Authenticate } from '../website-model/src/ability/authenticate';
protractor.browser.ignoreSynchronization = true;
export = function selectItemSteps() {
let actor = Actor.named('Bruno').whoCan(BrowseTheWeb.using(protractor.browser));
this.Given(/^that "([^"]*)" is logged in to his "([^"]*)" account$/, function (name: string, pageUrl: string) {
return actor.attemptsTo(
Start.LaunchUrl(pageUrl, name),
);
});
this.When(/^he searches and adds an item from "([^"]*)" section to his shopping bag$/, function (gender:string) {
return actor.attemptsTo(
AddItemsToShoppingBag.called(gender)
);
});
this.Then(/^he can place the order$/, function () {
return actor.attemptsTo(
// PlaceOrder.hjgkhaksdjh()
);
// expect(james.toSee(thankYouPageElementsMap(lbl_thank_you).Displayed)).eventually.equal('Thank You');
});
}
// login-user.ts
import { Task, step, PerformsTasks } from "serenity-js/lib/screenplay";
import { Click, Enter } from "serenity-js/lib/screenplay-protractor";
import { homePageElementsMap } from "../interactions/html-elements/pages-elements-maps/home-page-elements-maps";
import { loginPageElementsMap } from "../interactions/html-elements/pages-elements-maps/login-page-elements-map";
export class LoginUser implements Task {
static called(name: string): LoginUser {
return new LoginUser(name);
}
@step('{0} Login Page - Login Bruno')
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
Click.on(homePageElementsMap.lnk_login),
Enter.theValue('test@test.com').into(loginPageElementsMap.txt_login_email),
Enter.theValue('password111').into(loginPageElementsMap.txt_login_pwd),
Click.on(loginPageElementsMap.btn_login)
);
}
constructor(private name: string) {
}
}