I'm trying to automate the IE in C#. My Problem is that it's always busy.
I have a Wait-Method
private void WaitForComplete()
{
int elapsedSeconds = 0;
bool isDocumentBusy = browser.Busy;
int TimeoutSeconds = 5;
while (browser.Busy && elapsedSeconds < TimeoutSeconds)
{
Thread.Sleep(1000);
elapsedSeconds++;
}
}
And this is one of my Methods
public bool Forward()
{
if (browser == null)
return false;
int loopCount = 10;
while (browser.Busy && loopCount > 0)
{
Thread.Sleep(500);
loopCount--;
}
browser.GoForward();
return true;
}
I tried both with the Sleep in the Method and the Wait-Method.
I have also methods for switching the Tabs or create new tabs etc. It's the same for every Method.
Do you have a clue whats the point of this Problem?
Thanks!!!
Ok i found a solution.
The wait-method is nearly correct
private void WaitForComplete()
{
int elapsedSeconds = 0;
int TimeoutSeconds = 5;
while (browser.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE && elapsedSeconds != TimeoutSeconds)
{
Thread.Sleep(1000);
elapsedSeconds++;
}
}
it worked for me like this.