MCPcopy Index your code
hub / github.com/eclipse-che/che / waitVisibility

Method waitVisibility

tests/e2e/utils/DriverHelper.ts:95–158  ·  view source on GitHub ↗
(
		elementLocator: By,
		timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM,
		polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
	)

Source from the content-addressed store, hash-verified

93 }
94
95 async waitVisibility(
96 elementLocator: By,
97 timeout: number = TIMEOUT_CONSTANTS.TS_SELENIUM_CLICK_ON_VISIBLE_ITEM,
98 polling: number = TIMEOUT_CONSTANTS.TS_SELENIUM_DEFAULT_POLLING
99 ): Promise<WebElement> {
100 const attempts: number = Math.ceil(timeout / polling);
101 Logger.trace(`${elementLocator}`);
102
103 for (let i: number = 0; i < attempts; i++) {
104 let element: WebElement;
105 try {
106 element = await this.driver.wait(until.elementLocated(elementLocator), polling);
107 } catch (err) {
108 if (i >= attempts - 1) {
109 Logger.error(`failed with exception, out of attempts - ${err}`);
110 throw err;
111 }
112
113 if (err instanceof error.TimeoutError) {
114 if (attempts !== 1) {
115 // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
116 Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
117 }
118 continue;
119 }
120
121 if (err instanceof error.NoSuchWindowError) {
122 // sometimes waitVisibility fails with NoSuchWindowError when the check is run too soon before the page loads
123 Logger.trace(`failed with NoSuchWindow exception. Attempt #${i + 1}, retrying with ${polling}ms timeout`);
124 continue;
125 }
126
127 Logger.error(`failed with an unexpected exception - ${err}`);
128 throw err;
129 }
130
131 try {
132 const visibleWebElement: WebElement = await this.driver.wait(until.elementIsVisible(element), polling);
133 Logger.trace('element is located and is visible.');
134 return visibleWebElement;
135 } catch (err) {
136 if (err instanceof error.TimeoutError) {
137 if (attempts !== 1) {
138 // waitVisibility was spamming other methods when the number of attempts was 1 - only show message if attempts > 1
139 Logger.trace(`polling timed out attempt #${i + 1}, retrying with ${polling}ms timeout`);
140 }
141 continue;
142 }
143
144 if (err instanceof error.StaleElementReferenceError) {
145 Logger.debug(`stale element error - ${JSON.stringify(err)}`);
146 await this.wait(polling);
147 continue;
148 }
149
150 Logger.error(`failed with an unexpected exception - ${err}`);
151 throw err;
152 }

Callers 15

waitAllVisibilityMethod · 0.95
waitAndClickMethod · 0.95
waitAndGetCssValueMethod · 0.95
typeMethod · 0.95
clearMethod · 0.95
enterValueMethod · 0.95
waitAndGetTextMethod · 0.95
getProjectViewSessionMethod · 0.80

Calls 4

waitMethod · 0.95
traceMethod · 0.80
errorMethod · 0.80
debugMethod · 0.80

Tested by 2

checkDialogButtonFunction · 0.64
checkDialogButtonFunction · 0.64