<titledata-rh="true">Page.waitForXPath() 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.waitforxpath"><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.waitForXPath() method | Puppeteer"><metadata-rh="true"name="description"content="Wait for the xpath to appear in page. If at the moment of calling the method the xpath already exists, the method will return immediately. If the xpath doesn't appear after the timeout milliseconds of waiting, the function will throw."><metadata-rh="true"property="og:description"content="Wait for the xpath to appear in page. If at the moment of calling the method the xpath already exists, the method will return immediately. If the xpath 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.waitforxpath"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.page.waitforxpath"hreflang="en"><linkdata-rh="true"rel="alternate"href="https://pptr.dev/next/api/puppeteer.page.waitforxpath"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>xpath</code> to appear in page. If at the moment of calling the method the <code>xpath</code> already exists, the method will return immediately. If the <code>xpath</code> doesn't appear after the <code>timeout</code> milliseconds of waiting, the function will throw.</p>
<h4class="anchor anchorWithStickyNavbar_LWe7"id="signature">Signature:<ahref="#signature"class="hash-link"aria-label="Direct link to Signature:"title="Direct link to Signature:"></a></h4>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="parameters">Parameters<ahref="#parameters"class="hash-link"aria-label="Direct link to Parameters"title="Direct link to Parameters"></a></h2>
<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>xpath</td><td>string</td><td>A <ahref="https://developer.mozilla.org/en-US/docs/Web/XPath"target="_blank"rel="noopener noreferrer">xpath</a> of an element to wait for</td></tr><tr><td>options</td><td><ahref="/next/api/puppeteer.waitforselectoroptions">WaitForSelectorOptions</a></td><td><em>(Optional)</em> Optional waiting parameters</td></tr></tbody></table>
<p>Promise which resolves when element specified by xpath string is added to DOM. Resolves to <code>null</code> if waiting for <code>hidden: true</code> and xpath is not found in DOM, otherwise resolves to <code>ElementHandle</code>.</p>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="remarks">Remarks<ahref="#remarks"class="hash-link"aria-label="Direct link to Remarks"title="Direct link to Remarks"></a></h2>
<p>The optional Argument <code>options</code> have properties:</p>
<ul>
<li>
<p><code>visible</code>: A boolean to 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>: A boolean 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>: A number which is 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>
</li>
</ul>
<h2class="anchor anchorWithStickyNavbar_LWe7"id="example">Example<ahref="#example"class="hash-link"aria-label="Direct link to Example"title="Direct link to Example"></a></h2>