1616// along with this program. If not, see http://www.gnu.org/licenses/.
1717//
1818
19+ import WireLocators
1920import XCTest
2021
2122class AccountSettingsPage : PageModel {
2223
2324 override var pageMainElement : XCUIElement {
24- accountSettingsPageHeader
25- }
26-
27- var accountSettingsPageHeader : XCUIElement {
28- app. staticTexts [ " Account " ]
25+ nameField
2926 }
3027
3128 var nameField : XCUIElement {
32- app. descendants ( matching : . any ) [ " NameField " ] . firstMatch
29+ app. textFields [ Locators . AccountSettingsPage . nameField . rawValue ]
3330 }
3431
3532 var usernameField : XCUIElement {
36- app. descendants ( matching : . any ) [ " UsernameField " ] . firstMatch
33+ app. staticTexts [ Locators . AccountSettingsPage . usernameField . rawValue ]
3734 }
3835
3936 var emailField : XCUIElement {
40- app. descendants ( matching : . any ) [ " EmailField " ] . firstMatch
37+ app. staticTexts [ Locators . AccountSettingsPage . emailField . rawValue ]
4138 }
4239
4340 var domainField : XCUIElement {
44- app. descendants ( matching: . any) [ " DomainFieldDisabled " ] . firstMatch
41+ app. descendants ( matching: . any) [ Locators . AccountSettingsPage . domainFieldDisabled . rawValue ] . firstMatch
4542 }
4643
4744 var logoutButton : XCUIElement {
48- app. staticTexts [ " Log Out " ]
45+ app. staticTexts [ Locators . AccountSettingsPage . logOut . rawValue ]
4946 }
5047
5148 var deleteAccountButtonOnAccount : XCUIElement {
52- app. descendants ( matching: . any) [ " Delete AccountField " ] . firstMatch
49+ app. descendants ( matching: . any) [ Locators . AccountSettingsPage . deleteAccountField . rawValue ] . firstMatch
5350 }
5451
5552 var oKButtonOnDeleteAccountAlert : XCUIElement {
56- app. buttons [ " OK " ]
53+ app. buttons [ Locators . AccountSettingsPage . ok . rawValue ]
5754 }
5855
59- var backToSettingsButton : XCUIElement {
60- app. buttons [ " Settings " ]
56+ var backToPreviousPage : XCUIElement {
57+ app. navigationBars . buttons. element ( boundBy : 0 )
6158 }
6259
6360 var backupOrRestoreButton : XCUIElement {
64- app. descendants ( matching: . any) [ " Back up or RestoreField " ] . firstMatch
61+ app. descendants ( matching: . any) [ Locators . AccountSettingsPage . backuporRestoreField . rawValue ] . firstMatch
6562 }
6663
6764 var resetPasswordButton : XCUIElement {
68- app. descendants ( matching: . any) [ " Reset Password " ] . firstMatch
65+ app. descendants ( matching: . any) [ Locators . AccountSettingsPage . resetPasswordField . rawValue ] . firstMatch
6966 }
7067
7168 func getAccountName( ) -> String ? {
72- nameField. value as? String
69+ XCTAssertTrue (
70+ nameField. waitForExistence ( timeout: 5.0 ) ,
71+ " NameField should exist before reading account name "
72+ )
73+ return nameField. value as? String
7374 }
7475
7576 func getUsername( ) -> String {
@@ -85,9 +86,7 @@ class AccountSettingsPage: PageModel {
8586 }
8687
8788 func backToSettings( ) throws -> SettingsPage {
88- if backToSettingsButton. exists {
89- backToSettingsButton. tap ( )
90- }
89+ backToPreviousPage. tap ( )
9190 return try SettingsPage ( )
9291 }
9392
@@ -115,15 +114,17 @@ class AccountSettingsPage: PageModel {
115114 }
116115
117116 func goBackToSettingsPage( ) throws -> SettingsPage {
117+
118118 if app. iPadOnly ( ) {
119119 return try SettingsPage ( )
120120 }
121- backToSettingsButton . tap ( )
121+ backToPreviousPage . tap ( )
122122 return try SettingsPage ( )
123123 }
124124
125125 func tapOnResetPasswordButton( ) throws -> WebViewPage {
126126 resetPasswordButton. tap ( )
127127 return try WebViewPage ( )
128128 }
129+
129130}
0 commit comments