@@ -18,43 +18,60 @@ export class LoginPage {
1818 this . usernameInput = page . locator ( 'input#username' ) ;
1919 this . passwordInput = page . locator ( 'input#password' ) ;
2020 this . sessionLocationSelect = page . locator ( 'ul#sessionLocation.select' ) ;
21- this . loginButton = page . locator ( 'button #loginButton' ) ;
21+ this . loginButton = page . locator ( 'input #loginButton.btn.confirm ' ) ;
2222 this . errorMessage = page . locator ( '.alert.alert-danger' ) ;
2323 this . errorMessageSessionLocationSelect = page . locator ( '#sessionLocationError' ) ;
2424 }
2525
26+
2627 async navigate ( ) {
2728 await this . page . goto ( this . baseUrl ) ;
29+ await this . page . waitForLoadState ( 'domcontentloaded' ) ;
2830 await expect ( this . page ) . toHaveTitle ( this . expectedTitle ) ;
2931 }
32+
3033 async login ( username : string , password : string , location : string ) {
31- await this . usernameInput . fill ( username ) ;
32- await this . passwordInput . fill ( password ) ;
33- await this . sessionLocationSelect . selectOption ( location ) ;
34- await this . loginButton . click ( ) ;
34+ await this . usernameInput . fill ( username ) ;
35+ await this . passwordInput . fill ( password ) ;
36+ //await this.page.locator(`ul#sessionLocation.select >> text=${location}`).click();
37+ if ( location ) {
38+ await this . page . locator ( `ul#sessionLocation.select >> text=${ location } ` ) . click ( ) ;
3539 }
40+ await this . loginButton . click ( ) ;
41+ }
3642
3743 async invalidLogin ( username : string , password : string , location : string ) {
38- await this . usernameInput . fill ( username ) ;
39- await this . passwordInput . fill ( password ) ;
40- await this . sessionLocationSelect . selectOption ( location ) ;
41- await this . loginButton . click ( ) ;
44+ await this . usernameInput . fill ( username ) ;
45+ await this . passwordInput . fill ( password ) ;
46+ //await this.page.locator(`ul#sessionLocation.select >> text=${location}`).click();
47+ if ( location ) {
48+ await this . page . locator ( `ul#sessionLocation.select >> text=${ location } ` ) . click ( ) ;
4249 }
50+ await this . loginButton . click ( ) ;
51+ }
52+
53+ async loginWithoutLocation ( username : string , password : string ) {
54+ await this . usernameInput . fill ( username ) ;
55+ await this . passwordInput . fill ( password ) ;
56+ await this . loginButton . click ( ) ;
57+ }
4358
4459 async assertErrorMessage ( expectedMessage : string ) {
45- await expect ( this . errorMessage ) . toHaveText ( expectedMessage ) ;
60+ await expect ( this . errorMessage ) . toContainText ( expectedMessage ) ;
4661 }
4762
4863 async assertSessionLocationError ( expectedMessage : string ) {
49- await expect ( this . errorMessageSessionLocationSelect ) . toHaveText ( expectedMessage ) ;
64+ await expect ( this . errorMessageSessionLocationSelect ) . toContainText ( expectedMessage ) ;
5065 }
66+
5167 async verifySessionLocations ( expectedLocations : string [ ] ) {
52- const options = this . sessionLocationSelect . locator ( 'option' ) ;
53- const optionCount = await options . count ( ) ;
54- let actualLocations : string [ ] = [ ] ;
55- for ( let i = 0 ; i < optionCount ; i ++ ) {
56- actualLocations . push ( await options . nth ( i ) . innerText ( ) ) ;
57- }
58- expect ( actualLocations ) . toEqual ( expectedLocations ) ;
59- }
60- }
68+ const options = this . sessionLocationSelect . locator ( 'li' ) ;
69+ const optionCount = await options . count ( ) ;
70+ let actualLocations : string [ ] = [ ] ;
71+ for ( let i = 0 ; i < optionCount ; i ++ ) {
72+ actualLocations . push ( ( await options . nth ( i ) . innerText ( ) ) . trim ( ) ) ;
73+ }
74+ expect ( actualLocations . sort ( ) ) . toEqual ( expectedLocations . sort ( ) ) ;
75+ }
76+
77+ }
0 commit comments