move users in the users object to make loginWithProgile general purpose (#6270)

* move users in the users object to make loginWithProgile general puropose

* add loginProfile in login page too

* fix

* fix

* fix

* fix

* fix

* fix

* more fix

* fix

* fix

* fix

* change

* fix script

* fix
This commit is contained in:
Eugenio Romano
2020-10-26 17:46:54 +00:00
committed by GitHub
parent c6a3da2a74
commit fca378a12b
51 changed files with 140 additions and 127 deletions

View File

@@ -91,9 +91,9 @@ export class ApiService {
* Example: loginWithProfile('admin')
*/
async loginWithProfile(profileName: string): Promise<void> {
const profile = browser.params.testConfig[profileName];
const profile = browser.params.testConfig.users[profileName];
if (profile) {
await this.apiService.login(profile.email, profile.password);
await this.apiService.login(profile.username, profile.password);
} else {
throw new Error(`Login profile "${profileName}" not found on "browser.params.testConfig".`);
}

View File

@@ -40,7 +40,7 @@ export class UsersActions {
async createUser(userModel?: UserModel): Promise<UserModel> {
if (!this.api.apiService.isLoggedIn()) {
await this.api.apiService.login(browser.params.testConfig.admin.email, browser.params.testConfig.admin.password);
await this.api.apiService.login(browser.params.testConfig.users.admin.username, browser.params.testConfig.users.admin.password);
}
const user = new UserModel({ ...(userModel ? userModel : {}) });

View File

@@ -53,6 +53,15 @@ export class LoginPage {
await BrowserVisibility.waitUntilElementIsVisible(this.txtPasswordBasicAuth);
}
async loginWithProfile(profileName: string): Promise<void> {
const profile = browser.params.testConfig.users[profileName];
if (profile) {
await this.login(profile.username, profile.password);
} else {
throw new Error(`Login profile "${profileName}" not found on "browser.params.testConfig".`);
}
}
async login(username: string, password: string) {
Logger.log('Login With ' + username);