0

I am now using PuppeteerSharp (Version 1.20.0) to visit one web site via proxy. If I enable global proxy settings, then I can use Google Chrome to visit the web site, but I can't see any Cookie Accept Button, or it had once, but after I clicked it, it no longer appears.

However, when using PuppeteerSharp, such Cookie Accept Button always appears, if I ignore it, then almost any of the PuppeteerSharp selects are not working any more. If I use Google Chrome, I can install Puppeteer Recorder to save the mouse action, so I can try to find a way to click on the Cookie Accept Button, but if I use PuppeteerSharp, I can't install Puppeteer Recorder, therefore, finding a way to click on the Cookie Accept Button seems difficult, please advice. By the way, the following picture shows the Cookie Accept Button. enter image description here

Jo zyd
  • 59
  • 3
  • 7

1 Answers1

0

I think you will find easy to translate the code from puppeteer recorder to Puppeteer-Sharp. At least you can get the selectors from there.

Once you have those selectors you could do 3 things:

One option is setting a directory where the browser can store the cookies using the UserDataDir property. You could open the browser BrowserFetcher downloads and click that button.

A better solution is executing a script using EvaluateFunctionAsync to check if you have the cookies button and click it (using the selector you got from the recorder). Your code will be more flexible.

Last option would be downloading Chromie 77 or higher and launch it using ExecutablePath.

hardkoded
  • 18,915
  • 3
  • 52
  • 64
  • Hello: thanks for your reply. However, the issue is: I already installed Puppeteer recorder in Google Chrome, I can't install it again. But Google Chrome didn't show the Cookie Accept Button, I think I already accepted it long time ago. – Jo zyd Oct 09 '19 at 15:32