title: Change from JS Puppeteer code to PuppeteerSharp C#
body: <p>I have <code>Javascript puppeteer</code> code, and <code>PuppeteerSharp for C#</code>. I know that this libraries are similar, and i know their sites. </p>
  
  <p>But my problem that i barely can manage this libraries, there are alot of methods for each lib, and it hard to find needed methods, even i have working example written on JS. </p>
  
  <p>Please help me rewrite JS code to C#, so it would do similar things. Or at least function names, for example JS (puppeteer) method = C# (puppeteerSharp) method.</p>
  
  <pre><code>(async function main() {
        try {
          const browser = await puppeteer.launch();
          const [page] = await browser.pages();
          page.setDefaultTimeout(0);
  
          await page.goto('www.example.com');
  
          await page.waitForSelector('#search-content button.btn-icon');
          let count = 0;
          while (await page.$('#search-content button.btn-icon') !== null &amp;&amp; count != 1) {
            const articlesForNow = (await page.$$('#search-content article')).length;
            console.log(`Articles for now: ${articlesForNow}. Getting more...`);
            count += 1;
            await Promise.all([
              page.evaluate(
                () =&gt; {
                  document.querySelector('#search-content button.btn-icon').click();
                }
              ),
              page.waitForFunction(
                old =&gt; document.querySelectorAll('#search-content article').length &gt; old, {},
                articlesForNow
              ),
            ]);
          }
  
          const articlesAll = (await page.$$('#search-content article')).length;
          console.log(`All articles: ${articlesAll}.`);
  
          fs.writeFileSync('full.html', await page.content());
  
          fs.writeFileSync('articles.html', await page.evaluate(
            () =&gt; document.querySelector('#search-content div.b-filter__inner').outerHTML
          ));
  
          fs.appendFileSync('articles.txt', await page.evaluate(
                (fr) =&gt; {
                  let items = document.querySelectorAll(".product__body");
                  let appartmentsData = "";
  
                  for (let i = 0; i &lt; items.length; i++) {
                    let itemLink = items[i].querySelector(".product__link").href;
                    let itemName = items[i].querySelector(".product__link strong").innerHTML;
                    let itemPrice = items[i].querySelector(".product__value").innerHTML;
  
                    return appartmentsData;
                  }, fr
                ));
                // rest of the code
  </code></pre>
  
  <p>That what I have so far:</p>
  
  <pre><code>using(var browser = await Puppeteer.LaunchAsync(new LaunchOptions())) {
   var page = await browser.NewPageAsync();
   await page.GoToAsync(LINK);
   await page.WaitForSelectorAsync("#search-content button.btn-icon");
  
   while (await page.QuerySelectorAsync("#search-content button.btn-icon") != null) {
    var articlesForNow = await page.QuerySelectorAllAsync("#search-content article");
  
    Console.WriteLine("Items proceed: " + articlesForNow.Length);
  
    for (int i = 0; i &lt; articlesForNow.Length; i++) {
     string itemOuterHtml = await articlesForNow[i].EvaluateFunctionAsync &lt; string &gt; ("e =&gt; e.outerHTML");
    }
  
    await page.WaitForSelectorAsync("#search-content button.btn-icon").EvaluateFunctionAsync("e =&gt; e.click()");
   }
  }
  </code></pre>
  
  <p>But It's infinity counting and does not stop. After element is 1275 it throws the error about my method in while loop. </p>
  
  <pre><code>PuppeteerSharp.WaitTaskTimeoutException: waiting for selector '#search-content button.btn-icon' failed: timeout 30000ms exceeded
  </code></pre>