Can someone assist me with my code? I am attempting to write a test in Playwright that navigates to the forgot password page, creates a new password, and then tries to log in using that new password. However, I am encountering an issue with retrieving the return value. Here is the code snippet below, any guidance on how to resolve it would be much appreciated:
async createNewPassword(email: string) {
const { faker } = await require("@faker-js/faker");
const password = faker.internet.password();
await this.forgot_password_email_field.fill(email);
const email_field = await this.forgot_password_email_field.inputValue();
await this.forgot_password_field.fill(password);
const new_password = await this.forgot_password_field.inputValue();
await this.forgot_password_confirm_field.fill(new_password);
await this.forgot_password_save_button.click();
console.log(new_password);
return new_password;
}
async loginNewPassword(email: string) {
let new_login_password = this.createNewPassword();
console.log(new_login_password);
await this.email_field.fill(email);
await this.password_field.fill(await new_login_password);
await this.login_button.click();
}
I am struggling to capture the new password from the "createNewPassword" function and use it in the "loginNewPassword" function.
I have attempted to retrieve the return value like this, but without success:
let new_login_password = this.createNewPassword();