Puppeteer sharp - run a javascript function and get div when finish execution RRS feed

  • Question

  • Hello,

    i'm trying to do several tests with Puppeterr sharp but it's the first time that I work with it and I don't have very clear the syntax.

    I have to open a page that I have on a server, and then run a javascript function (loadPageData('4', true)) that I have defined which can take about 15 minutes (in that page). When the function finishes, it fills a div tag in that page. I need that untill the javascript function is executed and finished it does not pass to another instruction, but I do not know the syntax to use. Could you help me? what do I have to put in order to get the content of the div resultDIV?

    Part of my code:

    using (var browser = await Puppeteer.LaunchAsync(options))
    using (var page = await browser.NewPageAsync())
    await page.GoToAsync("http://.../mipagina.aspx");
    page.DefaultNavigationTimeout = 100000;
    string funcionEjecutar = "loadPageData('4', true)";
    var res = await page.EvaluateExpressionAsync(funcionEjecutar); //funciona pero no espera a que termine de ejecutarse la función y yo necesito que me devuelva el contenido del div


    • Edited by bambu81 Wednesday, October 14, 2020 11:52 AM
    • Moved by CoolDadTx Wednesday, October 14, 2020 2:54 PM Third Party Product
    Wednesday, October 14, 2020 10:36 AM

All replies

  • Hello,

    First off the way you posted for the most part is unreadable, second, this library is a unsupported item here as this forum is for C#.

    You need to post where the author watches, stackoverflow using puppeteer-sharp as a tag as seen here.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    profile for Karen Payne on Stack Exchange

    Wednesday, October 14, 2020 11:25 AM