<titledata-rh="true">Page.waitForSelector() method | Puppeteer</title><metadata-rh="true"name="viewport"content="width=device-width,initial-scale=1"><metadata-rh="true"name="twitter:card"content="summary_large_image"><metadata-rh="true"property="og:url"content="https://pptr.dev/next/api/puppeteer.page.waitforselector"><metadata-rh="true"property="og:locale"content="en"><metadata-rh="true"name="docsearch:language"content="en"><metadata-rh="true"name="docsearch:counter"content="3"><metadata-rh="true"property="og:title"content="Page.waitForSelector() method | Puppeteer"><metadata-rh="true"name="description"content="Wait for the selector to appear in page. If at the moment of calling the method the selector already exists, the method will return immediately. If the selector doesn't appear after the timeout milliseconds of waiting, the function will throw."><metadata-rh="true"property="og:description"content="Wait for the selector to appear in page. If at the moment of calling the method the selector already exists, the method will return immediately. If the selector doesn't appear after the timeout milliseconds of waiting, the function will throw."><linkdata-rh="true"rel="icon"href="/img/favicon.ico"><linkdata-rh="true"rel="canonical"href="https://pptr.dev/next/api/puppeteer.page.waitforselector"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.page.waitforselector"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.page.waitforselector"hreflang="x-default"><linkdata-rh="true"rel="preconnect"href="https://DVKY664LG7-dsn.algolia.net"crossorigin="anonymous"><linkrel="search"type="application/opensearchdescription+xml"title="Puppeteer"href="/opensearch.xml">
<p>Wait for the <code>selector</code> to appear in page. If at the moment of calling the method the <code>selector</code> already exists, the method will return immediately. If the <code>selector</code> doesn't appear after the <code>timeout</code> milliseconds of waiting, the function will throw.</p>
<h4class="anchor anchorWithStickyNavbar_FNw8"id="signature">Signature:<aclass="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"href="/next/api/puppeteer.page.waitforselector#signature"></a></h4>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="parameters">Parameters<aclass="hash-link"aria-label="Direct link to Parameters"title="Direct link to Parameters"href="/next/api/puppeteer.page.waitforselector#parameters"></a></h2>
<table><thead><tr><th><p>Parameter</p></th><th><p>Type</p></th><th><p>Description</p></th></tr></thead><tbody><tr><td><p>selector</p></td><td><p>Selector</p></td><td><p>A <ahref="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors"target="_blank"rel="noopener noreferrer">selector</a> of an element to wait for</p></td></tr><tr><td><p>options</p></td><td><p><ahref="/next/api/puppeteer.waitforselectoroptions">WaitForSelectorOptions</a></p></td><td><p><em>(Optional)</em> Optional waiting parameters</p></td></tr></tbody></table>
<p>Promise which resolves when element specified by selector string is added to DOM. Resolves to <code>null</code> if waiting for hidden: <code>true</code> and selector is not found in DOM.</p>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="remarks">Remarks<aclass="hash-link"aria-label="Direct link to Remarks"title="Direct link to Remarks"href="/next/api/puppeteer.page.waitforselector#remarks"></a></h2>
<p>The optional Parameter in Arguments <code>options</code> are:</p>
<ul>
<li>
<p><code>visible</code>: A boolean wait for element to be present in DOM and to be visible, i.e. to not have <code>display: none</code> or <code>visibility: hidden</code> CSS properties. Defaults to <code>false</code>.</p>
</li>
<li>
<p><code>hidden</code>: Wait for element to not be found in the DOM or to be hidden, i.e. have <code>display: none</code> or <code>visibility: hidden</code> CSS properties. Defaults to <code>false</code>.</p>
</li>
<li>
<p><code>timeout</code>: maximum time to wait for in milliseconds. Defaults to <code>30000</code> (30 seconds). Pass <code>0</code> to disable timeout. The default value can be changed by using the <ahref="/next/api/puppeteer.page.setdefaulttimeout">Page.setDefaultTimeout()</a> method.</p>
<h2class="anchor anchorWithStickyNavbar_FNw8"id="example">Example<aclass="hash-link"aria-label="Direct link to Example"title="Direct link to Example"href="/next/api/puppeteer.page.waitforselector#example"></a></h2>