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

  • Thread starter Thread starter bambu81
  • Start date Start date
B

bambu81

Guest
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;
try
{
string funcionEjecutar = "cargarDatosPagina ('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
}
catch(){
}

Thanks

Continue reading...
 
Back
Top