I am using a C # WebBrowswer control, and I have a problem when, when I click a button, such as "Next", when the page is not already loaded, the program tries to continue, but instead gives me a zero error.
Is there a function for the program to wait for the page to load?
I tried to put a while loop in a program that checks the title of an html page, but then the program freezes. Something like freezing a program:
while(!webbrowser1.Document.Title.ToString().Equals("NextPageTitle"))
{
}
::NextCommands::
It does not work, I tried this and the "fblqf" button is not pressed. but does not return a null error.
public void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("q").SetAttribute("value", "חחח");
webBrowser1.Document.GetElementById("btnK").InvokeMember("Click");
webBrowser1.DocumentCompleted += webBrowser1_DocumentCompleted;
}
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
webBrowser1.Document.GetElementById("fblqf").InvokeMember("Click");
}
Decision:
public void button1_Click(object sender, EventArgs e)
{
webBrowser1.Document.GetElementById("q").SetAttribute("value", "חחח");
webBrowser1.Document.GetElementById("btnK").InvokeMember("Click");
int x=0;
while (x==0)
{
System.Windows.Forms.Application.DoEvents();
if(webBrowser1.Document.GetElementById("pnnext") != null)
break;
}
webBrowser1.Document.GetElementById("pnnext").InvokeMember("Click");
webBrowser1.Document.GetElementById("q").Focus();
}
hagai source
share