11import { Page , Locator , expect } from "@playwright/test" ;
2- import settings from "../tests/config/settings.json" ;
32import { faker } from "@faker-js/faker/locale/en" ;
43
54export class RegistrationPage {
@@ -17,6 +16,7 @@ export class RegistrationPage {
1716 readonly countryDropdown : Locator ;
1817 readonly registerButton : Locator ;
1918 readonly loginHeader : Locator ;
19+ readonly registrationUrl : string ;
2020
2121 constructor ( page : Page ) {
2222 this . page = page ;
@@ -33,34 +33,35 @@ export class RegistrationPage {
3333 this . countryDropdown = page . locator ( "select#country" ) ;
3434 this . registerButton = page . locator ( "//button[@type='submit']" ) ;
3535 this . loginHeader = page . locator ( "//h3[text()='Login']" ) ;
36+ this . registrationUrl = `${ process . env . BASE_URL } /auth/register` ;
3637 }
3738
38- async navigateToRegistration ( ) {
39- await this . page . goto ( settings . REGISTRATION_URL ) ;
40- }
39+ async navigateToRegistration ( ) {
40+ await this . page . goto ( this . registrationUrl ) ;
41+ }
4142
42- async fillRegistrationForm ( ) {
43- await this . firstNameInput . fill ( faker . person . firstName ( ) ) ;
44- await this . lastNameInput . fill ( faker . person . lastName ( ) ) ;
45- await this . dobInput . fill ( "1990-01-01" ) ;
46- await this . streetInput . fill ( faker . location . streetAddress ( ) ) ;
47- await this . postalCodeInput . fill ( faker . location . zipCode ( ) ) ;
48- await this . cityInput . fill ( faker . location . city ( ) ) ;
49- await this . stateInput . fill ( faker . location . state ( ) ) ;
50- await this . countryDropdown . selectOption ( { label : "Canada" } ) ;
51- const phoneNumber = faker . string . numeric ( 10 ) ;
52- await this . phoneInput . fill ( phoneNumber ) ;
53- await this . emailInput . fill ( faker . internet . email ( ) ) ;
54- await this . passwordInput . fill ( settings . PASSWORD ) ;
55- }
43+ async fillRegistrationForm ( ) {
44+ await this . firstNameInput . fill ( faker . person . firstName ( ) ) ;
45+ await this . lastNameInput . fill ( faker . person . lastName ( ) ) ;
46+ await this . dobInput . fill ( "1990-01-01" ) ;
47+ await this . streetInput . fill ( faker . location . streetAddress ( ) ) ;
48+ await this . postalCodeInput . fill ( faker . location . zipCode ( ) ) ;
49+ await this . cityInput . fill ( faker . location . city ( ) ) ;
50+ await this . stateInput . fill ( faker . location . state ( ) ) ;
51+ await this . countryDropdown . selectOption ( { label : "Canada" } ) ;
52+ const phoneNumber = faker . string . numeric ( 10 ) ;
53+ await this . phoneInput . fill ( phoneNumber ) ;
54+ await this . emailInput . fill ( faker . internet . email ( ) ) ;
55+ await this . passwordInput . fill ( process . env . PASSWORD ! ) ;
56+ }
5657
57- async clickRegisterButton ( ) {
58- await this . registerButton . click ( ) ;
59- }
58+ async clickRegisterButton ( ) {
59+ await this . registerButton . click ( ) ;
60+ }
6061
61- async verifyRedirectionToLogin ( ) {
62- await this . loginHeader . waitFor ( { state : "visible" , timeout : 2000 } ) ;
63- expect ( this . page . url ( ) ) . toBe ( settings . LOGIN_URL ) ;
64- expect ( await this . loginHeader . textContent ( ) ) . toBe ( "Login" ) ;
65- }
62+ async verifyRedirectionToLogin ( ) {
63+ await this . loginHeader . waitFor ( { state : "visible" , timeout : 2000 } ) ;
64+ expect ( this . page . url ( ) ) . toBe ( ` ${ process . env . BASE_URL } /auth/login` ) ;
65+ expect ( await this . loginHeader . textContent ( ) ) . toBe ( "Login" ) ;
66+ }
6667}
0 commit comments