title: Puppeteer refresh until selector value change?
body: <p>I'm looking to have puppeteer refresh until a class I want to sign up for opens up. I plan on having the page refresh every 30 seconds or so until the selector to select the class opens. I've gone far enough to sign-in and get to the final page, but I can't wrap my head around the repeating part. A normal JS function brings an error.</p>
  <pre><code>page2.waitForNavigation()
  await page2.waitFor(4000)
  await page2.select('select[name=&quot;country&quot;]', &quot;USA&quot;)
  await page2.click('#searchZip');
  
  function findClass() {  
  page2.waitForNavigation()
  await page2.waitFor(4000)
  await page2.click('#showAvailableOnly');
  await page2.evaluate(() =&gt; {
  let el = document.querySelector(&quot;.dataTables_empty&quot;)
  result = el.innerText
  if (result = &quot;No matching records found&quot;) {
      console.log(&quot;Could not find any open test centers. Waiting 60 seconds to refresh.&quot;);
      
  </code></pre>
  <blockquote>
  <p>I want to have puppeteer wait 30 seconds here, and then run the code after <code>findClass()</code> again, until the <code>result</code> changes.</p>
  </blockquote>
  <pre><code>} else {
      console.log(&quot;Found opening!&quot;);
  }})     
  }
  </code></pre>
  <p>I would appreciate any help, as I am pretty new to puppeteer, or nodejs in general. Thank you so much!</p>