10 examples of 'jquery wait for element to exist' in JavaScript

Every line of 'jquery wait for element to exist' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
15wait(elem) {
16 browser.waitForExist(elem);
17}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

92async findWithWait(element) {
93 try {
94 await this.driver.wait(webdriver.until.elementLocated(element), Twait);
95 return await this.driver.findElements(element);
96 } catch(err) {
97 return null;
98 }
99}
98async findWithWait(element) {
99 try {
100 await this.driver.wait(webdriver.until.elementLocated(element), Twait);
101 return await this.driver.findElements(element);
102 }
103 catch (err) {
104 return null;
105 }
106}
40async 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}
41function waitForElement(selector, callback) {
42 if (document.querySelector(selector)) {
43 return callback()
44 } else {
45 setTimeout(waitForElement.bind(this, selector, callback), 300)
46 }
47}
209function waitForElement(selector, callback) {
210 waitFor(function() {
211 return !!$(selector).length;
212 }, callback);
213}
120public async waitForExistNot(wait: number = 3000) {
121 return await this._webio.waitForExist(this._searchParams, wait, true);
122}
113public waitAndFindVisibleElement(timeoutMultiplier = 1): Promise<WebElement> {
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<WebElement>(condition, LazyWebElement.WAIT_TIME * timeoutMultiplier),
125 );
126}
121waitForElement(name) {
122 this.t.expect(Selector(`[data-test-id="${name}"]`, OPTS))
123}
77export function waitForElementInVisibility (_element ) {
78 return browser.wait(expCond.invisibilityOf(_element)).catch((error) => console.log(`${_element.locator()} waitForElementInVisibility:`, error));
79}

Related snippets