@eclipse-che/che-e2e 7.74.0-dev-1d09cb7 → 7.74.0-dev-aace77a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/.eslintignore +10 -0
  2. package/.eslintrc.js +197 -0
  3. package/.prettierignore +10 -0
  4. package/.prettierrc.json +10 -0
  5. package/CODE_STYLE.md +144 -0
  6. package/README.md +47 -47
  7. package/configs/inversify.config.ts +39 -14
  8. package/configs/inversify.types.ts +44 -30
  9. package/configs/mocharc.ts +21 -24
  10. package/constants/API_TEST_CONSTANTS.ts +67 -0
  11. package/constants/BASE_TEST_CONSTANTS.ts +80 -0
  12. package/constants/CHROME_DRIVER_CONSTANTS.ts +42 -0
  13. package/constants/FACTORY_TEST_CONSTANTS.ts +61 -0
  14. package/constants/MONACO_CONSTANTS.ts +25 -0
  15. package/constants/OAUTH_CONSTANTS.ts +67 -0
  16. package/constants/PLUGIN_TEST_CONSTANTS.ts +15 -0
  17. package/constants/REPORTER_CONSTANTS.ts +53 -0
  18. package/constants/TIMEOUT_CONSTANTS.ts +131 -0
  19. package/dist/configs/inversify.config.js +36 -9
  20. package/dist/configs/inversify.config.js.map +1 -1
  21. package/dist/configs/inversify.types.js +19 -5
  22. package/dist/configs/inversify.types.js.map +1 -1
  23. package/dist/configs/mocharc.js +13 -16
  24. package/dist/configs/mocharc.js.map +1 -1
  25. package/dist/constants/{APITestConstants.js → API_TEST_CONSTANTS.js} +12 -12
  26. package/dist/constants/API_TEST_CONSTANTS.js.map +1 -0
  27. package/dist/constants/{BaseTestConstants.js → BASE_TEST_CONSTANTS.js} +16 -16
  28. package/dist/constants/BASE_TEST_CONSTANTS.js.map +1 -0
  29. package/dist/constants/CHROME_DRIVER_CONSTANTS.js +36 -0
  30. package/dist/constants/CHROME_DRIVER_CONSTANTS.js.map +1 -0
  31. package/dist/constants/{FactoryTestConstants.js → FACTORY_TEST_CONSTANTS.js} +14 -13
  32. package/dist/constants/FACTORY_TEST_CONSTANTS.js.map +1 -0
  33. package/dist/constants/{MonacoConstants.js → MONACO_CONSTANTS.js} +7 -7
  34. package/dist/constants/MONACO_CONSTANTS.js.map +1 -0
  35. package/dist/constants/{OAuthConstants.js → OAUTH_CONSTANTS.js} +14 -14
  36. package/dist/constants/OAUTH_CONSTANTS.js.map +1 -0
  37. package/dist/constants/{PluginsTestConstants.js → PLUGIN_TEST_CONSTANTS.js} +7 -7
  38. package/dist/constants/PLUGIN_TEST_CONSTANTS.js.map +1 -0
  39. package/dist/constants/{ReporterConstants.js → REPORTER_CONSTANTS.js} +12 -12
  40. package/dist/constants/REPORTER_CONSTANTS.js.map +1 -0
  41. package/dist/constants/{TimeoutConstants.js → TIMEOUT_CONSTANTS.js} +24 -24
  42. package/dist/constants/TIMEOUT_CONSTANTS.js.map +1 -0
  43. package/dist/driver/ChromeDriver.js +12 -22
  44. package/dist/driver/ChromeDriver.js.map +1 -1
  45. package/dist/index.js +18 -12
  46. package/dist/index.js.map +1 -1
  47. package/dist/pageobjects/dashboard/CreateWorkspace.js +15 -15
  48. package/dist/pageobjects/dashboard/CreateWorkspace.js.map +1 -1
  49. package/dist/pageobjects/dashboard/Dashboard.js +20 -21
  50. package/dist/pageobjects/dashboard/Dashboard.js.map +1 -1
  51. package/dist/pageobjects/dashboard/Workspaces.js +55 -60
  52. package/dist/pageobjects/dashboard/Workspaces.js.map +1 -1
  53. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js +58 -48
  54. package/dist/pageobjects/dashboard/workspace-details/WorkspaceDetails.js.map +1 -1
  55. package/dist/pageobjects/git-providers/OauthPage.js +22 -20
  56. package/dist/pageobjects/git-providers/OauthPage.js.map +1 -1
  57. package/dist/pageobjects/ide/CheCodeLocatorLoader.js +26 -12
  58. package/dist/pageobjects/ide/CheCodeLocatorLoader.js.map +1 -1
  59. package/dist/pageobjects/login/interfaces/ICheLoginPage.js +2 -2
  60. package/dist/pageobjects/login/interfaces/IOcpLoginPage.js +2 -2
  61. package/dist/pageobjects/login/kubernetes/DexLoginPage.js +14 -14
  62. package/dist/pageobjects/login/kubernetes/DexLoginPage.js.map +1 -1
  63. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js +7 -7
  64. package/dist/pageobjects/login/kubernetes/KubernetesLoginPage.js.map +1 -1
  65. package/dist/pageobjects/login/openshift/OcpLoginPage.js +24 -28
  66. package/dist/pageobjects/login/openshift/OcpLoginPage.js.map +1 -1
  67. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js +13 -16
  68. package/dist/pageobjects/login/openshift/OcpRedHatLoginPage.js.map +1 -1
  69. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js +9 -9
  70. package/dist/pageobjects/login/openshift/OcpUserLoginPage.js.map +1 -1
  71. package/dist/pageobjects/login/openshift/RedHatLoginPage.js +19 -23
  72. package/dist/pageobjects/login/openshift/RedHatLoginPage.js.map +1 -1
  73. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js +20 -19
  74. package/dist/pageobjects/login/openshift/RegularUserOcpCheLoginPage.js.map +1 -1
  75. package/dist/pageobjects/openshift/OcpApplicationPage.js +11 -11
  76. package/dist/pageobjects/openshift/OcpApplicationPage.js.map +1 -1
  77. package/dist/pageobjects/openshift/OcpImportFromGitPage.js +24 -24
  78. package/dist/pageobjects/openshift/OcpImportFromGitPage.js.map +1 -1
  79. package/dist/pageobjects/openshift/OcpMainPage.js +30 -30
  80. package/dist/pageobjects/openshift/OcpMainPage.js.map +1 -1
  81. package/dist/specs/MochaHooks.js +33 -27
  82. package/dist/specs/MochaHooks.js.map +1 -1
  83. package/dist/specs/SmokeTest.spec.js +17 -17
  84. package/dist/specs/SmokeTest.spec.js.map +1 -1
  85. package/dist/specs/api/ContainerOverridesAPI.spec.js +8 -6
  86. package/dist/specs/api/ContainerOverridesAPI.spec.js.map +1 -1
  87. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js +27 -24
  88. package/dist/specs/api/DevfileAcceptanceTestAPI.spec.js.map +1 -1
  89. package/dist/specs/api/EmptyWorkspaceAPI.spec.js +17 -17
  90. package/dist/specs/api/EmptyWorkspaceAPI.spec.js.map +1 -1
  91. package/dist/specs/api/PodOverridesAPI.spec.js +10 -8
  92. package/dist/specs/api/PodOverridesAPI.spec.js.map +1 -1
  93. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js +10 -10
  94. package/dist/specs/dashboard-samples/EmptyWorkspace.spec.js.map +1 -1
  95. package/dist/specs/dashboard-samples/Quarkus.spec.js +13 -13
  96. package/dist/specs/dashboard-samples/Quarkus.spec.js.map +1 -1
  97. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js +52 -52
  98. package/dist/specs/dashboard-samples/RecommendedExtensions.spec.js.map +1 -1
  99. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js +23 -19
  100. package/dist/specs/devconsole-intergration/DevConsoleIntegration.spec.js.map +1 -1
  101. package/dist/specs/factory/Factory.spec.js +38 -41
  102. package/dist/specs/factory/Factory.spec.js.map +1 -1
  103. package/dist/specs/factory/NoSetupRepoFactory.spec.js +52 -50
  104. package/dist/specs/factory/NoSetupRepoFactory.spec.js.map +1 -1
  105. package/dist/specs/factory/RefusedOAuthFactory.spec.js +49 -51
  106. package/dist/specs/factory/RefusedOAuthFactory.spec.js.map +1 -1
  107. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js +45 -42
  108. package/dist/specs/miscellaneous/PredefinedNamespace.spec.js.map +1 -1
  109. package/dist/tests-library/LoginTests.js +13 -13
  110. package/dist/tests-library/LoginTests.js.map +1 -1
  111. package/dist/tests-library/ProjectAndFileTests.js +9 -7
  112. package/dist/tests-library/ProjectAndFileTests.js.map +1 -1
  113. package/dist/tests-library/WorkspaceHandlingTests.js +22 -19
  114. package/dist/tests-library/WorkspaceHandlingTests.js.map +1 -1
  115. package/dist/utils/BrowserTabsUtil.js +21 -21
  116. package/dist/utils/BrowserTabsUtil.js.map +1 -1
  117. package/dist/utils/CheReporter.js +91 -65
  118. package/dist/utils/CheReporter.js.map +1 -1
  119. package/dist/utils/DevWorkspaceConfigurationHelper.js +34 -15
  120. package/dist/utils/DevWorkspaceConfigurationHelper.js.map +1 -1
  121. package/dist/utils/DevfilesRegistryHelper.js +34 -18
  122. package/dist/utils/DevfilesRegistryHelper.js.map +1 -1
  123. package/dist/utils/DriverHelper.js +73 -68
  124. package/dist/utils/DriverHelper.js.map +1 -1
  125. package/dist/utils/IContextParams.js +12 -0
  126. package/dist/utils/IContextParams.js.map +1 -0
  127. package/dist/utils/IKubernetesCommandLineToolsExecutor.js +3 -0
  128. package/dist/utils/IKubernetesCommandLineToolsExecutor.js.map +1 -0
  129. package/dist/utils/KubernetesCommandLineToolsExecutor.js +146 -107
  130. package/dist/utils/KubernetesCommandLineToolsExecutor.js.map +1 -1
  131. package/dist/utils/Logger.js +18 -19
  132. package/dist/utils/Logger.js.map +1 -1
  133. package/dist/utils/ScreenCatcher.js +26 -16
  134. package/dist/utils/ScreenCatcher.js.map +1 -1
  135. package/dist/utils/ShellExecutor.js +29 -9
  136. package/dist/utils/ShellExecutor.js.map +1 -1
  137. package/dist/utils/StringUtil.js +19 -9
  138. package/dist/utils/StringUtil.js.map +1 -1
  139. package/dist/utils/request-handlers/CheApiRequestHandler.js +29 -29
  140. package/dist/utils/request-handlers/CheApiRequestHandler.js.map +1 -1
  141. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js +12 -8
  142. package/dist/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.js.map +1 -1
  143. package/dist/utils/request-handlers/headers/IAuthorizationHeaderHandler.js +2 -2
  144. package/dist/utils/workspace/ApiUrlResolver.js +5 -5
  145. package/dist/utils/workspace/ApiUrlResolver.js.map +1 -1
  146. package/dist/utils/workspace/ITestWorkspaceUtil.js +2 -2
  147. package/dist/utils/workspace/TestWorkspaceUtil.js +25 -23
  148. package/dist/utils/workspace/TestWorkspaceUtil.js.map +1 -1
  149. package/dist/utils/workspace/WorkspaceStatus.js +2 -2
  150. package/dist/utils/workspace/WorkspaceStatus.js.map +1 -1
  151. package/driver/ChromeDriver.ts +45 -58
  152. package/driver/IDriver.ts +3 -3
  153. package/index.ts +11 -9
  154. package/package.json +59 -49
  155. package/pageobjects/dashboard/CreateWorkspace.ts +65 -55
  156. package/pageobjects/dashboard/Dashboard.ts +100 -100
  157. package/pageobjects/dashboard/Workspaces.ts +210 -186
  158. package/pageobjects/dashboard/workspace-details/WorkspaceDetails.ts +153 -131
  159. package/pageobjects/git-providers/OauthPage.ts +177 -166
  160. package/pageobjects/ide/CheCodeLocatorLoader.ts +51 -46
  161. package/pageobjects/login/interfaces/ICheLoginPage.ts +3 -3
  162. package/pageobjects/login/interfaces/IOcpLoginPage.ts +3 -3
  163. package/pageobjects/login/kubernetes/DexLoginPage.ts +31 -30
  164. package/pageobjects/login/kubernetes/KubernetesLoginPage.ts +15 -14
  165. package/pageobjects/login/openshift/OcpLoginPage.ts +51 -56
  166. package/pageobjects/login/openshift/OcpRedHatLoginPage.ts +27 -27
  167. package/pageobjects/login/openshift/OcpUserLoginPage.ts +15 -18
  168. package/pageobjects/login/openshift/RedHatLoginPage.ts +49 -46
  169. package/pageobjects/login/openshift/RegularUserOcpCheLoginPage.ts +43 -34
  170. package/pageobjects/openshift/OcpApplicationPage.ts +21 -19
  171. package/pageobjects/openshift/OcpImportFromGitPage.ts +68 -68
  172. package/pageobjects/openshift/OcpMainPage.ts +69 -69
  173. package/specs/MochaHooks.ts +59 -52
  174. package/specs/SmokeTest.spec.ts +47 -45
  175. package/specs/api/ContainerOverridesAPI.spec.ts +39 -26
  176. package/specs/api/DevfileAcceptanceTestAPI.spec.ts +110 -97
  177. package/specs/api/EmptyWorkspaceAPI.spec.ts +67 -58
  178. package/specs/api/PodOverridesAPI.spec.ts +48 -34
  179. package/specs/dashboard-samples/EmptyWorkspace.spec.ts +36 -36
  180. package/specs/dashboard-samples/Quarkus.spec.ts +41 -40
  181. package/specs/dashboard-samples/RecommendedExtensions.spec.ts +202 -183
  182. package/specs/devconsole-intergration/DevConsoleIntegration.spec.ts +85 -75
  183. package/specs/factory/Factory.spec.ts +184 -178
  184. package/specs/factory/NoSetupRepoFactory.spec.ts +233 -219
  185. package/specs/factory/RefusedOAuthFactory.spec.ts +223 -211
  186. package/specs/miscellaneous/PredefinedNamespace.spec.ts +70 -64
  187. package/tests-library/LoginTests.ts +34 -32
  188. package/tests-library/ProjectAndFileTests.ts +21 -18
  189. package/tests-library/WorkspaceHandlingTests.ts +98 -89
  190. package/tsconfig.json +15 -15
  191. package/utils/BrowserTabsUtil.ts +78 -74
  192. package/utils/CheReporter.ts +159 -157
  193. package/utils/DevWorkspaceConfigurationHelper.ts +63 -69
  194. package/utils/DevfilesRegistryHelper.ts +71 -57
  195. package/utils/DriverHelper.ts +728 -700
  196. package/utils/IContextParams.ts +26 -0
  197. package/utils/IKubernetesCommandLineToolsExecutor.ts +42 -0
  198. package/utils/KubernetesCommandLineToolsExecutor.ts +231 -183
  199. package/utils/Logger.ts +102 -125
  200. package/utils/ScreenCatcher.ts +57 -46
  201. package/utils/ShellExecutor.ts +23 -12
  202. package/utils/StringUtil.ts +49 -36
  203. package/utils/request-handlers/CheApiRequestHandler.ts +91 -88
  204. package/utils/request-handlers/headers/CheMultiuserAuthorizationHeaderHandler.ts +32 -21
  205. package/utils/request-handlers/headers/IAuthorizationHeaderHandler.ts +3 -3
  206. package/utils/workspace/ApiUrlResolver.ts +31 -26
  207. package/utils/workspace/ITestWorkspaceUtil.ts +31 -31
  208. package/utils/workspace/TestWorkspaceUtil.ts +152 -145
  209. package/utils/workspace/WorkspaceStatus.ts +5 -5
  210. package/constants/APITestConstants.ts +0 -57
  211. package/constants/BaseTestConstants.ts +0 -68
  212. package/constants/ChromeDriverConstants.ts +0 -46
  213. package/constants/FactoryTestConstants.ts +0 -51
  214. package/constants/MonacoConstants.ts +0 -22
  215. package/constants/OAuthConstants.ts +0 -57
  216. package/constants/PluginsTestConstants.ts +0 -15
  217. package/constants/ReporterConstants.ts +0 -45
  218. package/constants/TimeoutConstants.ts +0 -113
  219. package/dist/constants/APITestConstants.js.map +0 -1
  220. package/dist/constants/BaseTestConstants.js.map +0 -1
  221. package/dist/constants/ChromeDriverConstants.js +0 -44
  222. package/dist/constants/ChromeDriverConstants.js.map +0 -1
  223. package/dist/constants/FactoryTestConstants.js.map +0 -1
  224. package/dist/constants/MonacoConstants.js.map +0 -1
  225. package/dist/constants/OAuthConstants.js.map +0 -1
  226. package/dist/constants/PluginsTestConstants.js.map +0 -1
  227. package/dist/constants/ReporterConstants.js.map +0 -1
  228. package/dist/constants/TimeoutConstants.js.map +0 -1
  229. package/tslint.json +0 -126
@@ -1,5 +1,5 @@
1
- /*********************************************************************
2
- * Copyright (c) 2019-2023 Red Hat, Inc.
1
+ /** *******************************************************************
2
+ * copyright (c) 2019-2023 Red Hat, Inc.
3
3
  *
4
4
  * This program and the accompanying materials are made
5
5
  * available under the terms of the Eclipse Public License 2.0
@@ -13,705 +13,733 @@ import { TYPES } from '../configs/inversify.types';
13
13
  import { Actions, By, error, ThenableWebDriver, until, WebElement } from 'selenium-webdriver';
14
14
  import 'reflect-metadata';
15
15
  import { Logger } from './Logger';
16
- import { TimeoutConstants } from '../constants/TimeoutConstants';
16
+ import { TIMEOUT_CONSTANTS } from '../constants/TIMEOUT_CONSTANTS';
17
17
 
18
18
  @injectable()
19
19
  export class DriverHelper {
20
- private readonly driver: ThenableWebDriver;
21
-
22
- constructor(@inject(TYPES.Driver) driver: IDriver) {
23
- this.driver = driver.get() as ThenableWebDriver;
24
- }
25
-
26
- getAction(): Actions {
27
- Logger.trace();
28
-
29
- return this.driver.actions();
30
- }
31
-
32
- async isVisible(locator: By): Promise<boolean> {
33
- Logger.trace(`${locator}`);
34
-
35
- try {
36
- const element: WebElement = await this.driver.findElement(locator);
37
- return await element.isDisplayed();
38
- } catch {
39
- return false;
40
- }
41
- }
42
-
43
- async wait(milliseconds: number): Promise<void> {
44
- Logger.trace(`(${milliseconds} milliseconds)`);
45
-
46
- await this.driver.sleep(milliseconds);
47
- }
48
-
49
- async refreshPage(): Promise<void> {
50
- Logger.trace();
51
-
52
- await this.driver.navigate().refresh();
53
- }
54
-
55
- async waitVisibilityBoolean(locator: By,
56
- attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
57
- polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
58
-
59
- Logger.trace(`${locator}`);
60
-
61
- for (let i: number = 0; i < attempts; i++) {
62
- const isVisible: boolean = await this.isVisible(locator);
63
-
64
- if (isVisible) {
65
- return true;
66
- }
67
-
68
- await this.wait(polling);
69
- }
70
-
71
- return false;
72
- }
73
-
74
- async waitDisappearanceBoolean(locator: By,
75
- attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
76
- polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<boolean> {
77
-
78
- Logger.trace(`${locator}`);
79
-
80
- for (let i: number = 0; i < attempts; i++) {
81
- const isVisible: boolean = await this.isVisible(locator);
82
-
83
- if (!isVisible) {
84
- return true;
85
- }
86
-
87
- await this.wait(polling);
88
- }
89
-
90
- return false;
91
- }
92
-
93
- async waitVisibility(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
94
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
95
- const attempts: number = Math.ceil(timeout / polling);
96
-
97
- Logger.trace(`${elementLocator}`);
98
-
99
- for (let i: number = 0; i < attempts; i++) {
100
- let element: WebElement;
101
- try {
102
- element = await this.driver.wait(until.elementLocated(elementLocator), polling);
103
- } catch (err) {
104
- if (i >= attempts - 1) {
105
- Logger.error(`failed with exception, out of attempts - ${err}`);
106
- throw err;
107
- }
108
-
109
- if (err instanceof error.TimeoutError) {
110
- if (attempts !== 1) { // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
111
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
112
- }
113
- continue;
114
- }
115
-
116
- if (err instanceof error.NoSuchWindowError) { // sometimes waitVisibility fails with NoSuchWindowError when the check is run too soon before the page loads
117
- Logger.trace(`failed with NoSuchWindow exception. Attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
118
- continue;
119
- }
120
-
121
- Logger.error(`failed with an unexpected exception - ${err}`);
122
- throw err;
123
- }
124
-
125
- try {
126
- const visibleWebElement: WebElement = await this.driver.wait(until.elementIsVisible(element), polling);
127
- Logger.trace('element is located and is visible.');
128
- return visibleWebElement;
129
- } catch (err) {
130
- if (err instanceof error.TimeoutError) {
131
- if (attempts !== 1) { // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
132
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
133
- }
134
- continue;
135
- }
136
-
137
- if (err instanceof error.StaleElementReferenceError) {
138
- Logger.debug(`stale element error - ${err}`);
139
- await this.wait(polling);
140
- continue;
141
- }
142
-
143
- Logger.error(`failed with an unexpected exception - ${err}`);
144
- throw err;
145
- }
146
- }
147
-
148
- throw new error.TimeoutError(`Exceeded maximum visibility checking attempts for '${elementLocator}' element, timeouted after ${timeout}`);
149
- }
150
-
151
- async waitPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
152
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
153
- const attempts: number = Math.ceil(timeout / polling);
154
-
155
- Logger.trace(`${elementLocator}`);
156
-
157
- for (let i: number = 0; i < attempts; i++) {
158
- try {
159
- return await this.driver.wait(until.elementLocated(elementLocator), polling);
160
- } catch (err) {
161
- if (err instanceof error.TimeoutError) {
162
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
163
- continue;
164
- }
165
-
166
- if (err instanceof error.StaleElementReferenceError) {
167
- await this.wait(polling);
168
- continue;
169
- }
170
-
171
- Logger.error(`failed with an unexpected exception - ${err}`);
172
- throw err;
173
- }
174
- }
175
-
176
- throw new error.TimeoutError(`Exceeded maximum presence checking attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
177
- }
178
-
179
- async waitAllPresence(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<Array<WebElement>> {
180
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
181
- const attempts: number = Math.ceil(timeout / polling);
182
-
183
- Logger.trace(`${elementLocator}`);
184
-
185
- for (let i: number = 0; i < attempts; i++) {
186
- try {
187
- return await this.driver.wait(until.elementsLocated(elementLocator), polling);
188
- } catch (err) {
189
- if (err instanceof error.TimeoutError) {
190
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
191
- continue;
192
- }
193
-
194
- if (err instanceof error.StaleElementReferenceError) {
195
- await this.wait(polling);
196
- continue;
197
- }
198
-
199
- Logger.error(`failed with an unexpected exception - ${err}`);
200
- throw err;
201
- }
202
- }
203
-
204
- throw new error.TimeoutError(`Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`);
205
- }
206
-
207
- async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
208
- Logger.trace(`${locators}`);
209
-
210
- for (const elementLocator of locators) {
211
- await this.waitVisibility(elementLocator, timeout);
212
- }
213
- }
214
-
215
- async waitDisappearance(elementLocator: By,
216
- attempts: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
217
- polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
218
-
219
- Logger.trace(`${elementLocator}`);
220
-
221
- const isDisappeared: boolean = await this.waitDisappearanceBoolean(elementLocator, attempts, polling);
222
-
223
- if (!isDisappeared) {
224
- throw new error.TimeoutError(`Waiting attempts exceeded, element '${elementLocator}' is still visible`);
225
- }
226
- }
227
-
228
- async waitDisappearanceWithTimeout(elementLocator: By, timeout: number): Promise<void> {
229
- Logger.trace(`${elementLocator}`);
230
-
231
- await this.getDriver().wait(async () => {
232
- const isVisible: boolean = await this.isVisible(elementLocator);
233
-
234
- if (!isVisible) {
235
- return true;
236
- }
237
- }, timeout);
238
- }
239
-
240
- async waitAllDisappearance(locators: Array<By>,
241
- attemptsPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_ATTEMPTS,
242
- pollingPerLocator: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING): Promise<void> {
243
-
244
- Logger.trace(`${locators}`);
245
-
246
- for (const elementLocator of locators) {
247
- await this.waitDisappearance(elementLocator, attemptsPerLocator, pollingPerLocator);
248
- }
249
- }
250
-
251
- async waitAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
252
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
253
- const attempts: number = Math.ceil(timeout / polling);
254
-
255
- Logger.trace(`${elementLocator}`);
256
-
257
- for (let i: number = 0; i < attempts; i++) {
258
- let element: WebElement;
259
- try {
260
- element = await this.waitVisibility(elementLocator, polling);
261
- } catch (err) {
262
- if (i >= attempts - 1) {
263
- Logger.error(`failed with exception, out of attempts - ${err}`);
264
- throw err;
265
- }
266
-
267
- if (err instanceof error.TimeoutError) {
268
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
269
- continue;
270
- }
271
-
272
- Logger.error(`failed with an unexpected exception - ${err}`);
273
- throw err;
274
- }
275
-
276
- try {
277
- await element.click();
278
- return;
279
- } catch (err) {
280
- function isElementClickInterceptedOnLastAttempt(err: Error, i: number): boolean {
281
- return err instanceof error.ElementClickInterceptedError && i === attempts - 1;
282
- }
283
-
284
- if (err instanceof error.StaleElementReferenceError || err instanceof error.ElementClickInterceptedError) {
285
- Logger.debug(`${elementLocator} - ${err}`);
286
- await this.wait(polling);
287
- continue;
288
- }
289
-
290
- if (isElementClickInterceptedOnLastAttempt(err, i)) {
291
- Logger.debug(`element is not clickable, try to perform pointer click`);
292
- await this.getAction()
293
- .move({
294
- origin: await this.waitPresence(elementLocator)
295
- })
296
- .click()
297
- .perform();
298
- return;
299
- }
300
-
301
- Logger.error(`failed with an unexpected exception - ${err}`);
302
- throw err;
303
- }
304
- }
305
-
306
- throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
307
- }
308
-
309
- async waitAndGetElementAttribute(elementLocator: By, attribute: string,
310
- timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
311
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
312
- const attempts: number = Math.ceil(timeout / polling);
313
-
314
- Logger.trace(`${elementLocator} attribute: '${attribute}'`);
315
-
316
- for (let i: number = 0; i < attempts; i++) {
317
- let element: WebElement;
318
- try {
319
- element = await this.waitVisibility(elementLocator, polling);
320
- } catch (err) {
321
- if (i >= attempts - 1) {
322
- Logger.error(`failed with exception, out of attempts - ${err}`);
323
- throw err;
324
- }
325
-
326
- if (err instanceof error.TimeoutError) {
327
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
328
- continue;
329
- }
330
-
331
- Logger.error(`failed with an unexpected exception - ${err}`);
332
- throw err;
333
- }
334
-
335
- try {
336
- return await element.getAttribute(attribute);
337
- } catch (err) {
338
- if (err instanceof error.StaleElementReferenceError) {
339
- await this.wait(polling);
340
- continue;
341
- }
342
-
343
- Logger.error(`failed with an unexpected exception - ${err}`);
344
- throw err;
345
- }
346
- }
347
-
348
- throw new error.TimeoutError(`Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`);
349
- }
350
-
351
- async waitAndGetCssValue(elementLocator: By, cssAttribute: string,
352
- timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
353
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
354
- const attempts: number = Math.ceil(timeout / polling);
355
-
356
- Logger.trace(`${elementLocator} cssAttribute: ${cssAttribute}`);
357
-
358
- for (let i: number = 0; i < attempts; i++) {
359
- let element: WebElement;
360
- try {
361
- element = await this.waitVisibility(elementLocator, polling);
362
- } catch (err) {
363
- if (i >= attempts - 1) {
364
- Logger.error(`failed with exception, out of attempts - ${err}`);
365
- throw err;
366
- }
367
-
368
- if (err instanceof error.TimeoutError) {
369
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
370
- continue;
371
- }
372
-
373
- Logger.error(`failed with an unexpected exception - ${err}`);
374
- throw err;
375
- }
376
-
377
- try {
378
- return await element.getCssValue(cssAttribute);
379
- } catch (err) {
380
- if (err instanceof error.StaleElementReferenceError) {
381
- await this.wait(polling);
382
- continue;
383
- }
384
-
385
- Logger.error(`failed with an unexpected exception - ${err}`);
386
- throw err;
387
- }
388
- }
389
-
390
- throw new error.TimeoutError(`Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`);
391
- }
392
-
393
- async waitAttributeValue(elementLocator: By,
394
- attribute: string,
395
- expectedValue: string,
396
- timeout: number): Promise<void> {
397
-
398
- Logger.trace(`${elementLocator}`);
399
-
400
- await this.driver.wait(async () => {
401
- const attributeValue: string = await this.waitAndGetElementAttribute(elementLocator, attribute, timeout);
402
-
403
- return expectedValue === attributeValue;
404
- },
405
- timeout,
406
- `The '${attribute}' attribute value doesn't match with expected value '${expectedValue}'`);
407
- }
408
-
409
- async type(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
410
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
411
- const attempts: number = Math.ceil(timeout / polling);
412
-
413
- if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
414
- Logger.trace(`${elementLocator} text: ***`);
415
- } else {
416
- Logger.trace(`${elementLocator} text: ${text}`);
417
- }
418
-
419
- for (let i: number = 0; i < attempts; i++) {
420
- let element: WebElement;
421
- try {
422
- element = await this.waitVisibility(elementLocator, polling);
423
- } catch (err) {
424
- if (i >= attempts - 1) {
425
- Logger.error(`failed with exception, out of attempts - ${err}`);
426
- throw err;
427
- }
428
-
429
- if (err instanceof error.TimeoutError) {
430
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
431
- continue;
432
- }
433
-
434
- Logger.error(`failed with an unexpected exception - ${err}`);
435
- throw err;
436
- }
437
-
438
- try {
439
- await element.sendKeys(text);
440
- return;
441
- } catch (err) {
442
- if (err instanceof error.StaleElementReferenceError) {
443
- await this.wait(polling);
444
- continue;
445
- }
446
-
447
- Logger.error(`failed with an unexpected exception - ${err}`);
448
- throw err;
449
- }
450
- }
451
-
452
- throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
453
- }
454
-
455
- async typeToInvisible(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
456
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
457
- const attempts: number = Math.ceil(timeout / polling);
458
-
459
- Logger.trace(`${elementLocator} text: ${text}`);
460
-
461
- for (let i: number = 0; i < attempts; i++) {
462
- let element: WebElement;
463
- try {
464
- element = await this.waitPresence(elementLocator, polling);
465
- } catch (err) {
466
- if (i >= attempts - 1) {
467
- Logger.error(`failed with exception, out of attempts - ${err}`);
468
- throw err;
469
- }
470
-
471
- if (err instanceof error.TimeoutError) {
472
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
473
- continue;
474
- }
475
-
476
- Logger.error(`failed with an unexpected exception - ${err}`);
477
- throw err;
478
- }
479
-
480
- try {
481
- await element.sendKeys(text);
482
- return;
483
- } catch (err) {
484
- if (err instanceof error.StaleElementReferenceError) {
485
- await this.wait(polling);
486
- continue;
487
- }
488
-
489
- Logger.error(`failed with an unexpected exception - ${err}`);
490
- throw err;
491
- }
492
- }
493
-
494
- throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
495
- }
496
-
497
- async clear(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
498
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
499
- const attempts: number = Math.ceil(timeout / polling);
500
-
501
- Logger.trace(`${elementLocator}`);
502
-
503
- for (let i: number = 0; i < attempts; i++) {
504
- let element: WebElement;
505
- try {
506
- element = await this.waitVisibility(elementLocator, polling);
507
- } catch (err) {
508
- if (i >= attempts - 1) {
509
- Logger.error(`failed with exception, out of attempts - ${err}`);
510
- throw err;
511
- }
512
-
513
- if (err instanceof error.TimeoutError) {
514
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
515
- continue;
516
- }
517
-
518
- Logger.error(`failed with an unexpected exception - ${err}`);
519
- throw err;
520
- }
521
-
522
- try {
523
- await element.clear();
524
- return;
525
- } catch (err) {
526
- if (err instanceof error.StaleElementReferenceError) {
527
- await this.wait(polling);
528
- continue;
529
- }
530
-
531
- Logger.error(`failed with an unexpected exception - ${err}`);
532
- throw err;
533
- }
534
- }
535
-
536
- throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
537
- }
538
-
539
- async clearInvisible(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
540
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
541
- const attempts: number = Math.ceil(timeout / polling);
542
-
543
- Logger.trace(`${elementLocator}`);
544
-
545
- for (let i: number = 0; i < attempts; i++) {
546
- let element: WebElement;
547
- try {
548
- element = await this.waitPresence(elementLocator, polling);
549
- } catch (err) {
550
- if (i >= attempts - 1) {
551
- Logger.error(`failed with exception, out of attempts - ${err}`);
552
- throw err;
553
- }
554
-
555
- if (err instanceof error.TimeoutError) {
556
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
557
- continue;
558
- }
559
-
560
- Logger.error(`failed with an unexpected exception - ${err}`);
561
- throw err;
562
- }
563
-
564
- try {
565
- await element.clear();
566
- return;
567
- } catch (err) {
568
- if (err instanceof error.StaleElementReferenceError) {
569
- await this.wait(polling);
570
- continue;
571
- }
572
-
573
- Logger.error(`failed with an unexpected exception - ${err}`);
574
- throw err;
575
- }
576
- }
577
-
578
- throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
579
- }
580
-
581
- async enterValue(elementLocator: By, text: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
582
- if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
583
- Logger.trace(`${elementLocator} text: ***`);
584
- } else {
585
- Logger.trace(`${elementLocator} text: ${text}`);
586
- }
587
-
588
- await this.waitVisibility(elementLocator, timeout);
589
- await this.clear(elementLocator);
590
- await this.waitAttributeValue(elementLocator, 'value', '', timeout);
591
- await this.type(elementLocator, text, timeout);
592
- await this.waitAttributeValue(elementLocator, 'value', text, timeout);
593
- }
594
-
595
- async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise<void> {
596
- Logger.trace(`${iframeLocator}`);
597
-
598
- await this.driver.wait(until.ableToSwitchToFrame(iframeLocator), timeout);
599
- }
600
-
601
- async waitAndGetText(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
602
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
603
- const attempts: number = Math.ceil(timeout / polling);
604
-
605
- Logger.trace(`${elementLocator}`);
606
-
607
- for (let i: number = 0; i < attempts; i++) {
608
- let element: WebElement;
609
- try {
610
- element = await this.waitVisibility(elementLocator, polling);
611
- } catch (err) {
612
- if (i >= attempts - 1) {
613
- Logger.error(`failed with exception, out of attempts - ${err}`);
614
- throw err;
615
- }
616
-
617
- if (err instanceof error.TimeoutError) {
618
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
619
- continue;
620
- }
621
-
622
- Logger.error(`failed with an unexpected exception - ${err}`);
623
- throw err;
624
- }
625
-
626
- try {
627
- return await element.getText();
628
- } catch (err) {
629
- if (err instanceof error.StaleElementReferenceError) {
630
- await this.wait(polling);
631
- continue;
632
- }
633
-
634
- Logger.error(`failed with an unexpected exception - ${err}`);
635
- throw err;
636
- }
637
- }
638
-
639
- throw new error.TimeoutError(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
640
- }
641
-
642
- async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
643
- Logger.trace(`${elementLocator}`);
644
-
645
- return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout);
646
- }
647
-
648
- async waitUntilTrue(callback: any, timeout: number): Promise<void> {
649
- Logger.trace();
650
-
651
- await this.driver.wait(callback, timeout);
652
- }
653
-
654
- async scrollTo(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
655
- const polling: number = TimeoutConstants.TS_SELENIUM_DEFAULT_POLLING;
656
- const attempts: number = Math.ceil(timeout / polling);
657
-
658
- Logger.trace(`${elementLocator}`);
659
-
660
- for (let i: number = 0; i < attempts; i++) {
661
- let element: WebElement;
662
- try {
663
- element = await this.waitPresence(elementLocator, polling);
664
- } catch (err) {
665
- if (i >= attempts - 1) {
666
- Logger.error(`failed with exception, out of attempts - ${err}`);
667
- throw err;
668
- }
669
-
670
- if (err instanceof error.TimeoutError) {
671
- Logger.trace(`polling timed out attempt #${(i + 1)}, retrying with ${polling}ms timeout`);
672
- continue;
673
- }
674
-
675
- Logger.error(`failed with an unexpected exception - ${err}`);
676
- throw err;
677
- }
678
-
679
- try {
680
- await this.getDriver()
681
- .executeScript('arguments[0].scrollIntoView(true);', element);
682
- return;
683
- } catch (err) {
684
- if (err instanceof error.StaleElementReferenceError) {
685
- await this.wait(polling);
686
- continue;
687
- }
688
-
689
- Logger.error(`failed with an unexpected exception - ${err}`);
690
- throw err;
691
- }
692
- }
693
-
694
- throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
695
- }
696
-
697
- async scrollToAndClick(elementLocator: By, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
698
- await this.scrollTo(elementLocator, timeout);
699
- await this.waitAndClick(elementLocator, timeout);
700
- }
701
-
702
- async scrollToAndEnterValue(elementLocator: By, value: string, timeout: number = TimeoutConstants.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
703
- await this.scrollTo(elementLocator, timeout);
704
- await this.enterValue(elementLocator, value, timeout);
705
- }
706
-
707
- // method is useful to debug page object elements
708
- async highLightElement(element: WebElement): Promise<void> {
709
- await this.getDriver().executeScript('arguments[0].style.border=\'2px solid red\'', element);
710
- }
711
-
712
- getDriver(): ThenableWebDriver {
713
- Logger.trace();
714
-
715
- return this.driver;
716
- }
20
+ private readonly driver: ThenableWebDriver;
21
+
22
+ constructor(@inject(TYPES.Driver) driver: IDriver) {
23
+ this.driver = driver.get();
24
+ }
25
+
26
+ getAction(): Actions {
27
+ Logger.trace();
28
+
29
+ return this.driver.actions();
30
+ }
31
+
32
+ async isVisible(locator: By): Promise<boolean> {
33
+ Logger.trace(`${locator}`);
34
+
35
+ try {
36
+ const element: WebElement = await this.driver.findElement(locator);
37
+ return await element.isDisplayed();
38
+ } catch {
39
+ return false;
40
+ }
41
+ }
42
+
43
+ async wait(milliseconds: number): Promise<void> {
44
+ Logger.trace(`(${milliseconds} milliseconds)`);
45
+
46
+ await this.driver.sleep(milliseconds);
47
+ }
48
+
49
+ async refreshPage(): Promise<void> {
50
+ Logger.trace();
51
+
52
+ await this.driver.navigate().refresh();
53
+ }
54
+
55
+ async waitVisibilityBoolean(
56
+ locator: By,
57
+ attempts: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_ATTEMPTS,
58
+ polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
59
+ ): Promise<boolean> {
60
+ Logger.trace(`${locator}`);
61
+
62
+ for (let i: number = 0; i < attempts; i++) {
63
+ const isVisible: boolean = await this.isVisible(locator);
64
+
65
+ if (isVisible) {
66
+ return true;
67
+ }
68
+
69
+ await this.wait(polling);
70
+ }
71
+
72
+ return false;
73
+ }
74
+
75
+ async waitDisappearanceBoolean(
76
+ locator: By,
77
+ attempts: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_ATTEMPTS,
78
+ polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
79
+ ): Promise<boolean> {
80
+ Logger.trace(`${locator}`);
81
+
82
+ for (let i: number = 0; i < attempts; i++) {
83
+ const isVisible: boolean = await this.isVisible(locator);
84
+
85
+ if (!isVisible) {
86
+ return true;
87
+ }
88
+
89
+ await this.wait(polling);
90
+ }
91
+
92
+ return false;
93
+ }
94
+
95
+ async waitVisibility(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
96
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
97
+ const attempts: number = Math.ceil(timeout / polling);
98
+ Logger.trace(`${elementLocator}`);
99
+
100
+ for (let i: number = 0; i < attempts; i++) {
101
+ let element: WebElement;
102
+ try {
103
+ element = await this.driver.wait(until.elementLocated(elementLocator), polling);
104
+ } catch (err) {
105
+ if (i >= attempts - 1) {
106
+ Logger.error(`failed with exception, out of attempts - ${err}`);
107
+ throw err;
108
+ }
109
+
110
+ if (err instanceof error.TimeoutError) {
111
+ if (attempts !== 1) {
112
+ // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
113
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
114
+ }
115
+ continue;
116
+ }
117
+
118
+ if (err instanceof error.NoSuchWindowError) {
119
+ // sometimes waitVisibility fails with NoSuchWindowError when the check is run too soon before the page loads
120
+ Logger.trace(`failed with NoSuchWindow exception. Attempt #${i + 1}, retrying with ${polling}ms timeout`);
121
+ continue;
122
+ }
123
+
124
+ Logger.error(`failed with an unexpected exception - ${err}`);
125
+ throw err;
126
+ }
127
+
128
+ try {
129
+ const visibleWebElement: WebElement = await this.driver.wait(until.elementIsVisible(element), polling);
130
+ Logger.trace('element is located and is visible.');
131
+ return visibleWebElement;
132
+ } catch (err) {
133
+ if (err instanceof error.TimeoutError) {
134
+ if (attempts !== 1) {
135
+ // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
136
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
137
+ }
138
+ continue;
139
+ }
140
+
141
+ if (err instanceof error.StaleElementReferenceError) {
142
+ Logger.debug(`stale element error - ${JSON.stringify(err)}`);
143
+ await this.wait(polling);
144
+ continue;
145
+ }
146
+
147
+ Logger.error(`failed with an unexpected exception - ${err}`);
148
+ throw err;
149
+ }
150
+ }
151
+
152
+ throw new error.TimeoutError(
153
+ `Exceeded maximum visibility checking attempts for '${elementLocator}' element, timeouted after ${timeout}`
154
+ );
155
+ }
156
+
157
+ async waitPresence(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<WebElement> {
158
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
159
+ const attempts: number = Math.ceil(timeout / polling);
160
+ Logger.trace(`${elementLocator}`);
161
+
162
+ for (let i: number = 0; i < attempts; i++) {
163
+ try {
164
+ return await this.driver.wait(until.elementLocated(elementLocator), polling);
165
+ } catch (err) {
166
+ if (err instanceof error.TimeoutError) {
167
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
168
+ continue;
169
+ }
170
+
171
+ if (err instanceof error.StaleElementReferenceError) {
172
+ await this.wait(polling);
173
+ continue;
174
+ }
175
+
176
+ Logger.error(`failed with an unexpected exception - ${err}`);
177
+ throw err;
178
+ }
179
+ }
180
+
181
+ throw new error.TimeoutError(
182
+ `Exceeded maximum presence checking attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`
183
+ );
184
+ }
185
+
186
+ async waitAllPresence(
187
+ elementLocator: By,
188
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
189
+ ): Promise<Array<WebElement>> {
190
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
191
+ const attempts: number = Math.ceil(timeout / polling);
192
+ Logger.trace(`${elementLocator}`);
193
+
194
+ for (let i: number = 0; i < attempts; i++) {
195
+ try {
196
+ return await this.driver.wait(until.elementsLocated(elementLocator), polling);
197
+ } catch (err) {
198
+ if (err instanceof error.TimeoutError) {
199
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
200
+ continue;
201
+ }
202
+
203
+ if (err instanceof error.StaleElementReferenceError) {
204
+ await this.wait(polling);
205
+ continue;
206
+ }
207
+
208
+ Logger.error(`failed with an unexpected exception - ${err}`);
209
+ throw err;
210
+ }
211
+ }
212
+
213
+ throw new error.TimeoutError(
214
+ `Exceeded maximum presence checkings attempts, problems with 'StaleElementReferenceError' of '${elementLocator}' element`
215
+ );
216
+ }
217
+
218
+ async waitAllVisibility(locators: Array<By>, timeout: number): Promise<void> {
219
+ Logger.trace(`${locators}`);
220
+
221
+ for (const elementLocator of locators) {
222
+ await this.waitVisibility(elementLocator, timeout);
223
+ }
224
+ }
225
+
226
+ async waitDisappearance(
227
+ elementLocator: By,
228
+ attempts: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_ATTEMPTS,
229
+ polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
230
+ ): Promise<void> {
231
+ Logger.trace(`${elementLocator}`);
232
+
233
+ const isDisappeared: boolean = await this.waitDisappearanceBoolean(elementLocator, attempts, polling);
234
+
235
+ if (!isDisappeared) {
236
+ throw new error.TimeoutError(`Waiting attempts exceeded, element '${elementLocator}' is still visible`);
237
+ }
238
+ }
239
+
240
+ async waitAllDisappearance(
241
+ locators: Array<By>,
242
+ attemptsPerLocator: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_ATTEMPTS,
243
+ pollingPerLocator: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
244
+ ): Promise<void> {
245
+ Logger.trace(`${locators}`);
246
+
247
+ try {
248
+ for (const elementLocator of locators) {
249
+ await this.waitDisappearance(elementLocator, attemptsPerLocator, pollingPerLocator);
250
+ }
251
+ } catch (e) {
252
+ throw e;
253
+ }
254
+ }
255
+
256
+ async waitAndClick(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
257
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
258
+ const attempts: number = Math.ceil(timeout / polling);
259
+ Logger.trace(`${elementLocator}`);
260
+
261
+ for (let i: number = 0; i < attempts; i++) {
262
+ let element: WebElement;
263
+ try {
264
+ element = await this.waitVisibility(elementLocator, polling);
265
+ } catch (err) {
266
+ if (i >= attempts - 1) {
267
+ Logger.error(`failed with exception, out of attempts - ${err}`);
268
+ throw err;
269
+ }
270
+
271
+ if (err instanceof error.TimeoutError) {
272
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
273
+ continue;
274
+ }
275
+
276
+ Logger.error(`failed with an unexpected exception - ${err}`);
277
+ throw err;
278
+ }
279
+
280
+ try {
281
+ await element.click();
282
+ return;
283
+ } catch (err) {
284
+ function isElementClickInterceptedOnLastAttempt(err: any, i: number): boolean {
285
+ return err instanceof error.ElementClickInterceptedError && i === attempts - 1;
286
+ }
287
+
288
+ if (err instanceof error.StaleElementReferenceError || err instanceof error.ElementClickInterceptedError) {
289
+ Logger.debug(`${elementLocator} - ${JSON.stringify(err)}`);
290
+ await this.wait(polling);
291
+ continue;
292
+ }
293
+
294
+ if (isElementClickInterceptedOnLastAttempt(err, i)) {
295
+ Logger.debug('element is not clickable, try to perform pointer click');
296
+ await this.getAction()
297
+ .move({
298
+ origin: await this.waitPresence(elementLocator)
299
+ })
300
+ .click()
301
+ .perform();
302
+ return;
303
+ }
304
+
305
+ Logger.error(`failed with an unexpected exception - ${err}`);
306
+ throw err;
307
+ }
308
+ }
309
+
310
+ throw new error.TimeoutError(`Exceeded maximum clicking attempts, the '${elementLocator}' element is not clickable`);
311
+ }
312
+
313
+ async waitAndGetElementAttribute(
314
+ elementLocator: By,
315
+ attribute: string,
316
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
317
+ ): Promise<string> {
318
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
319
+ const attempts: number = Math.ceil(timeout / polling);
320
+ Logger.trace(`${elementLocator} attribute: '${attribute}'`);
321
+
322
+ for (let i: number = 0; i < attempts; i++) {
323
+ let element: WebElement;
324
+ try {
325
+ element = await this.waitVisibility(elementLocator, polling);
326
+ } catch (err) {
327
+ if (i >= attempts - 1) {
328
+ Logger.error(`failed with exception, out of attempts - ${err}`);
329
+ throw err;
330
+ }
331
+
332
+ if (err instanceof error.TimeoutError) {
333
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
334
+ continue;
335
+ }
336
+
337
+ Logger.error(`failed with an unexpected exception - ${err}`);
338
+ throw err;
339
+ }
340
+
341
+ try {
342
+ return await element.getAttribute(attribute);
343
+ } catch (err) {
344
+ if (err instanceof error.StaleElementReferenceError) {
345
+ await this.wait(polling);
346
+ continue;
347
+ }
348
+
349
+ Logger.error(`failed with an unexpected exception - ${err}`);
350
+ throw err;
351
+ }
352
+ }
353
+
354
+ throw new error.TimeoutError(
355
+ `Exceeded maximum gettin of the '${attribute}' attribute attempts, from the '${elementLocator}' element`
356
+ );
357
+ }
358
+
359
+ async waitAndGetCssValue(
360
+ elementLocator: By,
361
+ cssAttribute: string,
362
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
363
+ ): Promise<string> {
364
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
365
+ const attempts: number = Math.ceil(timeout / polling);
366
+ Logger.trace(`${elementLocator} cssAttribute: ${cssAttribute}`);
367
+
368
+ for (let i: number = 0; i < attempts; i++) {
369
+ let element: WebElement;
370
+ try {
371
+ element = await this.waitVisibility(elementLocator, polling);
372
+ } catch (err) {
373
+ if (i >= attempts - 1) {
374
+ Logger.error(`failed with exception, out of attempts - ${err}`);
375
+ throw err;
376
+ }
377
+
378
+ if (err instanceof error.TimeoutError) {
379
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
380
+ continue;
381
+ }
382
+
383
+ Logger.error(`failed with an unexpected exception - ${err}`);
384
+ throw err;
385
+ }
386
+
387
+ try {
388
+ return await element.getCssValue(cssAttribute);
389
+ } catch (err) {
390
+ if (err instanceof error.StaleElementReferenceError) {
391
+ await this.wait(polling);
392
+ continue;
393
+ }
394
+
395
+ Logger.error(`failed with an unexpected exception - ${err}`);
396
+ throw err;
397
+ }
398
+ }
399
+
400
+ throw new error.TimeoutError(
401
+ `Exceeded maximum gettin of the '${cssAttribute}' css attribute attempts, from the '${elementLocator}' element`
402
+ );
403
+ }
404
+
405
+ async waitAttributeValue(elementLocator: By, attribute: string, expectedValue: string, timeout: number): Promise<void> {
406
+ Logger.trace(`${elementLocator}`);
407
+
408
+ await this.driver.wait(
409
+ async (): Promise<boolean> => {
410
+ const attributeValue: string = await this.waitAndGetElementAttribute(elementLocator, attribute, timeout);
411
+
412
+ return expectedValue === attributeValue;
413
+ },
414
+ timeout,
415
+ `The '${attribute}' attribute value doesn't match with expected value '${expectedValue}'`
416
+ );
417
+ }
418
+
419
+ async type(elementLocator: By, text: string, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
420
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
421
+ const attempts: number = Math.ceil(timeout / polling);
422
+
423
+ if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
424
+ Logger.trace(`${elementLocator} text: ***`);
425
+ } else {
426
+ Logger.trace(`${elementLocator} text: ${text}`);
427
+ }
428
+
429
+ for (let i: number = 0; i < attempts; i++) {
430
+ let element: WebElement;
431
+ try {
432
+ element = await this.waitVisibility(elementLocator, polling);
433
+ } catch (err) {
434
+ if (i >= attempts - 1) {
435
+ Logger.error(`failed with exception, out of attempts - ${err}`);
436
+ throw err;
437
+ }
438
+
439
+ if (err instanceof error.TimeoutError) {
440
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
441
+ continue;
442
+ }
443
+
444
+ Logger.error(`failed with an unexpected exception - ${err}`);
445
+ throw err;
446
+ }
447
+
448
+ try {
449
+ await element.sendKeys(text);
450
+ return;
451
+ } catch (err) {
452
+ if (err instanceof error.StaleElementReferenceError) {
453
+ await this.wait(polling);
454
+ continue;
455
+ }
456
+
457
+ Logger.error(`failed with an unexpected exception - ${err}`);
458
+ throw err;
459
+ }
460
+ }
461
+
462
+ throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
463
+ }
464
+
465
+ async typeToInvisible(
466
+ elementLocator: By,
467
+ text: string,
468
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
469
+ ): Promise<void> {
470
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
471
+ const attempts: number = Math.ceil(timeout / polling);
472
+ Logger.trace(`${elementLocator} text: ${text}`);
473
+
474
+ for (let i: number = 0; i < attempts; i++) {
475
+ let element: WebElement;
476
+ try {
477
+ element = await this.waitPresence(elementLocator, polling);
478
+ } catch (err) {
479
+ if (i >= attempts - 1) {
480
+ Logger.error(`failed with exception, out of attempts - ${err}`);
481
+ throw err;
482
+ }
483
+
484
+ if (err instanceof error.TimeoutError) {
485
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
486
+ continue;
487
+ }
488
+
489
+ Logger.error(`failed with an unexpected exception - ${err}`);
490
+ throw err;
491
+ }
492
+
493
+ try {
494
+ await element.sendKeys(text);
495
+ return;
496
+ } catch (err) {
497
+ if (err instanceof error.StaleElementReferenceError) {
498
+ await this.wait(polling);
499
+ continue;
500
+ }
501
+
502
+ Logger.error(`failed with an unexpected exception - ${err}`);
503
+ throw err;
504
+ }
505
+ }
506
+
507
+ throw new error.TimeoutError(`Exceeded maximum typing attempts, to the '${elementLocator}' element`);
508
+ }
509
+
510
+ async clear(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
511
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
512
+ const attempts: number = Math.ceil(timeout / polling);
513
+ Logger.trace(`${elementLocator}`);
514
+
515
+ for (let i: number = 0; i < attempts; i++) {
516
+ let element: WebElement;
517
+ try {
518
+ element = await this.waitVisibility(elementLocator, polling);
519
+ } catch (err) {
520
+ if (i >= attempts - 1) {
521
+ Logger.error(`failed with exception, out of attempts - ${err}`);
522
+ throw err;
523
+ }
524
+
525
+ if (err instanceof error.TimeoutError) {
526
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
527
+ continue;
528
+ }
529
+
530
+ Logger.error(`failed with an unexpected exception - ${err}`);
531
+ throw err;
532
+ }
533
+
534
+ try {
535
+ await element.clear();
536
+ return;
537
+ } catch (err) {
538
+ if (err instanceof error.StaleElementReferenceError) {
539
+ await this.wait(polling);
540
+ continue;
541
+ }
542
+
543
+ Logger.error(`failed with an unexpected exception - ${err}`);
544
+ throw err;
545
+ }
546
+ }
547
+
548
+ throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
549
+ }
550
+
551
+ async clearInvisible(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
552
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
553
+ const attempts: number = Math.ceil(timeout / polling);
554
+ Logger.trace(`${elementLocator}`);
555
+
556
+ for (let i: number = 0; i < attempts; i++) {
557
+ let element: WebElement;
558
+ try {
559
+ element = await this.waitPresence(elementLocator, polling);
560
+ } catch (err) {
561
+ if (i >= attempts - 1) {
562
+ Logger.error(`failed with exception, out of attempts - ${err}`);
563
+ throw err;
564
+ }
565
+
566
+ if (err instanceof error.TimeoutError) {
567
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
568
+ continue;
569
+ }
570
+
571
+ Logger.error(`failed with an unexpected exception - ${err}`);
572
+ throw err;
573
+ }
574
+
575
+ try {
576
+ await element.clear();
577
+ return;
578
+ } catch (err) {
579
+ if (err instanceof error.StaleElementReferenceError) {
580
+ await this.wait(polling);
581
+ continue;
582
+ }
583
+
584
+ Logger.error(`failed with an unexpected exception - ${err}`);
585
+ throw err;
586
+ }
587
+ }
588
+
589
+ throw new error.TimeoutError(`Exceeded maximum clearing attempts, to the '${elementLocator}' element`);
590
+ }
591
+
592
+ async enterValue(
593
+ elementLocator: By,
594
+ text: string,
595
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
596
+ ): Promise<void> {
597
+ if (elementLocator.toString().toLocaleLowerCase().includes('password')) {
598
+ Logger.trace(`${elementLocator} text: ***`);
599
+ } else {
600
+ Logger.trace(`${elementLocator} text: ${text}`);
601
+ }
602
+
603
+ await this.waitVisibility(elementLocator, timeout);
604
+ await this.clear(elementLocator);
605
+ await this.waitAttributeValue(elementLocator, 'value', '', timeout);
606
+ await this.type(elementLocator, text, timeout);
607
+ await this.waitAttributeValue(elementLocator, 'value', text, timeout);
608
+ }
609
+
610
+ async waitAndSwitchToFrame(iframeLocator: By, timeout: number): Promise<void> {
611
+ Logger.trace(`${iframeLocator}`);
612
+
613
+ await this.driver.wait(until.ableToSwitchToFrame(iframeLocator), timeout);
614
+ }
615
+
616
+ async waitAndGetText(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<string> {
617
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
618
+ const attempts: number = Math.ceil(timeout / polling);
619
+ Logger.trace(`${elementLocator}`);
620
+
621
+ for (let i: number = 0; i < attempts; i++) {
622
+ let element: WebElement;
623
+ try {
624
+ element = await this.waitVisibility(elementLocator, polling);
625
+ } catch (err) {
626
+ if (i >= attempts - 1) {
627
+ Logger.error(`failed with exception, out of attempts - ${err}`);
628
+ throw err;
629
+ }
630
+
631
+ if (err instanceof error.TimeoutError) {
632
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
633
+ continue;
634
+ }
635
+
636
+ Logger.error(`failed with an unexpected exception - ${err}`);
637
+ throw err;
638
+ }
639
+
640
+ try {
641
+ return await element.getText();
642
+ } catch (err) {
643
+ if (err instanceof error.StaleElementReferenceError) {
644
+ await this.wait(polling);
645
+ continue;
646
+ }
647
+
648
+ Logger.error(`failed with an unexpected exception - ${err}`);
649
+ throw err;
650
+ }
651
+ }
652
+
653
+ throw new error.TimeoutError(`Exceeded maximum text obtaining attempts, from the '${elementLocator}' element`);
654
+ }
655
+
656
+ async waitAndGetValue(elementLocator: By, timeout: number): Promise<string> {
657
+ Logger.trace(`${elementLocator}`);
658
+
659
+ return await this.waitAndGetElementAttribute(elementLocator, 'value', timeout);
660
+ }
661
+
662
+ async waitUntilTrue(callback: any, timeout: number): Promise<void> {
663
+ Logger.trace();
664
+
665
+ await this.driver.wait(callback, timeout);
666
+ }
667
+
668
+ async scrollTo(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
669
+ const polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING;
670
+ const attempts: number = Math.ceil(timeout / polling);
671
+ Logger.trace(`${elementLocator}`);
672
+
673
+ for (let i: number = 0; i < attempts; i++) {
674
+ let element: WebElement;
675
+ try {
676
+ element = await this.waitPresence(elementLocator, polling);
677
+ } catch (err) {
678
+ if (i >= attempts - 1) {
679
+ Logger.error(`failed with exception, out of attempts - ${err}`);
680
+ throw err;
681
+ }
682
+
683
+ if (err instanceof error.TimeoutError) {
684
+ Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
685
+ continue;
686
+ }
687
+
688
+ Logger.error(`failed with an unexpected exception - ${err}`);
689
+ throw err;
690
+ }
691
+
692
+ try {
693
+ await this.getDriver().executeScript('arguments[0].scrollIntoView(true);', element);
694
+ return;
695
+ } catch (err) {
696
+ if (err instanceof error.StaleElementReferenceError) {
697
+ await this.wait(polling);
698
+ continue;
699
+ }
700
+
701
+ Logger.error(`failed with an unexpected exception - ${err}`);
702
+ throw err;
703
+ }
704
+ }
705
+
706
+ throw new error.TimeoutError(`Exceeded maximum mouse move attempts, for the '${elementLocator}' element`);
707
+ }
708
+
709
+ async scrollToAndClick(elementLocator: By, timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM): Promise<void> {
710
+ Logger.trace();
711
+
712
+ await this.scrollTo(elementLocator, timeout);
713
+ await this.waitAndClick(elementLocator, timeout);
714
+ }
715
+
716
+ async scrollToAndEnterValue(
717
+ elementLocator: By,
718
+ value: string,
719
+ timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM
720
+ ): Promise<void> {
721
+ Logger.trace();
722
+
723
+ await this.scrollTo(elementLocator, timeout);
724
+ await this.enterValue(elementLocator, value, timeout);
725
+ }
726
+
727
+ // method is useful to debug page object elements
728
+ async highLightElement(element: WebElement): Promise<void> {
729
+ Logger.trace();
730
+
731
+ await this.getDriver().executeScript('arguments[0].style.border="2px solid red"', element);
732
+ }
733
+
734
+ getDriver(): ThenableWebDriver {
735
+ Logger.trace();
736
+
737
+ return this.driver;
738
+ }
739
+
740
+ async navigateToUrl(url: string): Promise<void> {
741
+ Logger.trace();
742
+
743
+ await this.getDriver().navigate().to(url);
744
+ }
717
745
  }