There are lot of this kind of questions and I was not able to find a solution for my problem.
I have a webpage and after the webpage loads Ajax is called and it will load a table with data may be it takes 2 seconds.
I want the data inside that table.
When I try to access the table using document text It does not have the table HTML. It still have the initial HTML that has loaded before Ajax call.
webBrowser1.Update(); //Didn't work
Then I tried this didn't work
private void Timer_Tick(object sender, EventArgs e) //Interval of 5000
{
if (webBrowser1.ReadyState == WebBrowserReadyState.Complete)
{
HtmlElement element = webBrowser1.Document.GetElementById("tableType3");
if (element != null)
{
String webbrowsercontent = element.InnerHtml;
timer.Stop();
}
}
}
Then I tried this didn't work
private void WaitTillPageLoadsCompletly(WebBrowser webBrControl)
{
WebBrowserReadyState loadStatus;
int waittime = 20000;
int counter = 0;
while (true)
{
loadStatus = webBrControl.ReadyState;
Application.DoEvents();
if ((counter > waittime) || (loadStatus == WebBrowserReadyState.Uninitialized) || (loadStatus == WebBrowserReadyState.Loading) || (loadStatus == WebBrowserReadyState.Interactive))
{
break;
}
counter++;
}
counter = 0;
while (true)
{
loadStatus = webBrControl.ReadyState;
Application.DoEvents();
if (loadStatus == WebBrowserReadyState.Complete && webBrControl.IsBusy != true)
{
break;
}
counter++;
}
}
In debugging I saw the table contents in WebBrowser1.Document.NativeHtmlDocument2 which cant be accessed because of internal class.
Is there any other way to solve my problem.