Every line of 'jquery wait for page to load' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
139 async wait(pageCompleteCheck) { 140 const waitTime = this.options.pageCompleteWaitTime || 5000; 141 if (!pageCompleteCheck) { 142 pageCompleteCheck = this.options.pageCompleteCheckInactivity 143 ? pageCompleteCheckByInactivity 144 : defaultPageCompleteCheck; 145 // if using SPA just override 146 if (this.options.spa) { 147 pageCompleteCheck = spaCheck; 148 } 149 } 150 151 const driver = this.driver, 152 pageCompleteCheckTimeout = this.options.timeouts.pageCompleteCheck; 153 try { 154 const pageCompleteCheckCondition = new Condition( 155 'for page complete check script to return true', 156 function(d) { 157 return d.executeScript(pageCompleteCheck, waitTime).then(function(t) { 158 return t === true; 159 }); 160 } 161 ); 162 log.debug( 163 `Waiting for script pageCompleteCheck at most ${pageCompleteCheckTimeout} ms` 164 ); 165 log.verbose(`Waiting for script ${pageCompleteCheck}`); 166 await timeout( 167 driver.wait( 168 pageCompleteCheckCondition, 169 pageCompleteCheckTimeout, 170 undefined, 171 this.options.pageCompleteCheckPollTimeout || 200 172 ), 173 pageCompleteCheckTimeout, 174 `Running page complete check ${pageCompleteCheck} took too long ` 175 ); 176 log.debug(`Waiting after load event for ${waitTime} ms.`); 177 await delay(waitTime); 178 } catch (e) { 179 log.error('Failed to wait ' + e); 180 throw new UrlLoadError('Failed to wait ', { 181 cause: e 182 }); 183 } 184 }
79 waitForDocumentFullyLoaded() { 80 driver.waitUntil( 81 () => { 82 const webview = driver.execute(() => ({ state: document.readyState, title: document.title })); 83 84 return webview.state === DOCUMENT_READY_STATE.COMPLETE && webview.title !== ''; 85 }, 86 15000, 87 'Website not loaded', 88 100, 89 ); 90 }
64 async function loadPage (driver, url) { 65 await retryInterval(5, 1000, async function () { 66 await openPage(driver, url); 67 const title = await spinTitle(driver); 68 title.should.not.include('Cannot Open Page'); 69 }); 70 }
15 wait(elem) { 16 browser.waitForExist(elem); 17 }
40 async waitUntilLocated(element, Twaiting) { 41 let counter = Twaiting; 42 if (counter === undefined) counter = 180; 43 try { 44 do { 45 await this.driver.sleep(300); 46 if (await this.isElementLocated(element)) return true; 47 } while (counter-- > 0); 48 return false; 49 } 50 catch (err) { 51 return false; 52 } 53 }
4 waitUntilVisible() { 5 return super.waitUntilVisible().then(() => { 6 return this.loader().waitUntilHidden(); 7 }); 8 }
11 mainWin.addEventListener("load", function pageLoaded() { 12 timer.setTimeout(function delayedTest() { 13 var currentWidth = mainWin.innerWidth; 14 test.assert( originalWidth != currentWidth); 15 test.done(); 16 },500); 17 },false);
41 function waitForElement(selector, callback) { 42 if (document.querySelector(selector)) { 43 return callback() 44 } else { 45 setTimeout(waitForElement.bind(this, selector, callback), 300) 46 } 47 }
18 function waitUntilLoaded (window, timeout) { 19 var onStopLoading; 20 return Promise.fromNode(function (callback) { 21 onStopLoading = function () { 22 callback(null, window); 23 }; 24 window.webContents.on('did-stop-loading', onStopLoading); 25 26 }) 27 .timeout(timeout || 60000) 28 .finally(function () { 29 // clean up so we can reuse the window 30 window.webContents.removeListener('did-stop-loading', onStopLoading); 31 }) 32 .catch(Promise.TimeoutError, function (err) { 33 window.webContents.stop(); 34 throw err; 35 }); 36 }
113 public waitAndFindVisibleElement(timeoutMultiplier = 1): Promise { 114 const condition = new Condition(`for element to be visible ${this}`, async () => { 115 const [element] = await this.findElements(); 116 if (element) { 117 const displayed = await element.isDisplayed(); 118 return displayed && Promise.resolve(element); 119 } 120 return Promise.resolve(false); 121 }); 122 123 return Promise.resolve( 124 this.driver.wait(condition, LazyWebElement.WAIT_TIME * timeoutMultiplier), 125 ); 126 }