puppeteer-sharp icon indicating copy to clipboard operation
puppeteer-sharp copied to clipboard

puppeteer-sharp NavigationException Firefox

Open siilens opened this issue 3 years ago • 1 comments

Description

Please tell me, I can’t navigate to the page when using option "userdatadir" with firefox. The site opens in the browser, but i get an error while use

await page.GoToAsync

Browser browser = await Puppeteer.LaunchAsync(new LaunchOptions
        {
            Headless = false,
            ExecutablePath = "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
            Product = Product.Firefox,
            UserDataDir = @"C:\Users\Nihao\AppData\Roaming\Mozilla\Firefox\Profiles\fp8f64bb.Mika",
            DefaultViewport = null,
            IgnoreHTTPSErrors = true,
            Args = new[] { "-wait-for-browser" }
        });
 Page page = await browser.NewPageAsync();
 await page.GoToAsync("https://whoer.net"); //exception here

Exception

PuppeteerSharp.NavigationException: "Timeout of 30000 ms exceeded"

And Exception while use timeout 0

page.DefaultNavigationTimeout = 0;

PuppeteerSharp.NavigationException: "Navigation failed because browser has disconnected! PuppeteerSharp.FrameManager.d__42.MoveNext()

Everything works fine, when i dont use "UserDataDir" (Without profile). Maybe there is another way, how to use the Firefox Profile?

Versions

NET framework 4.6.1 Puppeteer 6.1.0

siilens avatar Jan 18 '22 22:01 siilens

I also faced with this exception, but my case is different and much simpler. I am running a standard chromiuim browser by:

        var browserFetcher = Puppeteer.CreateBrowserFetcher(new BrowserFetcherOptions());
        var revisionInfo = await browserFetcher.DownloadAsync(revision: BrowserFetcher.DefaultChromiumRevision);

        var browser = await Puppeteer.LaunchAsync(new LaunchOptions()
        {
            Headless = false,
            //SlowMo = 1000,
            DefaultViewport = new ViewPortOptions()
            {
                Width = 1024,
                Height = 800
            }
        });

        var pages = await browser.PagesAsync();           
        var page = pages[0];

        var response = await page.GoToAsync("https://whoer.net"); //If specify SlowMo property (allow), here is exception...`

I just noticed, when I trying to use SlowMo option (as enabled) then I facing to PuppeteerSharp.NavigationException: 'Timeout of 30000 ms exceeded': This exception was originally thrown at this call stack: PuppeteerSharp.Helpers.TaskHelper.WithTimeout.AnonymousMethod__0() in TaskHelper.cs PuppeteerSharp.Helpers.TaskHelper.WithTimeout(System.Threading.Tasks.Task, System.Func<System.Threading.Tasks.Task>, System.TimeSpan, System.Threading.CancellationToken) in TaskHelper.cs System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in ExceptionDispatchInfo.cs System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) in TaskAwaiter.cs System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) in TaskAwaiter.cs PuppeteerSharp.FrameManager.NavigateFrameAsync(PuppeteerSharp.Frame, string, PuppeteerSharp.NavigationOptions) in FrameManager.cs

without specify "SlowMo" all is working as expected

Context: VS 2019, .Net 5 target, ConsoleApplication, PuppeteerSharp 6.2.0 nuget package

Sergio1C avatar Apr 09 '22 11:04 Sergio1C

It seems that the website is blocking some requests in certain scenarios. As you are running that in helpful mode. Do you see the site loading or an Access is denied error?

kblok avatar Oct 14 '22 13:10 kblok