-
December 18th, 2010, 03:01 AM
#1
WebBrowser Control - Wait for page to process
I'm tryna click on an element that opens a window and in the window click on another element. the problem is that when I click that first element it takes some time for the page to process the window so it doesn't click the second element because it's executing the code while it's processing.
anyone has a solution? I tried sleep() but it's useless because it freezes the webbrowser control so it won't let the window open
-
December 19th, 2010, 06:08 AM
#2
Re: WebBrowser Control - Wait for page to process
Use DocumentCompleted event of webbrowser control.
-
December 21st, 2010, 11:41 AM
#3
Re: WebBrowser Control - Wait for page to process
I'm not talking about loading a document... I'm talking about an element inside the webpage!
How can I tell the code to wait until it finishes loading
-
December 23rd, 2010, 01:41 AM
#4
Re: WebBrowser Control - Wait for page to process
I guess unless all elements are loaded, that event isn't fired at all.
-
December 23rd, 2010, 09:17 AM
#5
Re: WebBrowser Control - Wait for page to process
I had the same problem, and the solution I found is:
this inside it's own form, all it is is a window with text of "Please wait a moment", and because it's showdialog() you freeze all input and code within the thread, but you don't hold up the thread to prevent the loading of the post processed data after documentcompleted is fired.
I don't even use documentcompleted in my scenario I just use,
random code statement;
wt.showdialog();
random code;
wt.showdialog();
Then within the code below, just adjust the timer for how much of a delay you NEED... It took some tweaking, but I've completely redone what it is I'm working on, so I won't need to use this approach... Instead I'm taking the extra effort of a comparison from each doccompleted... lot's of freakin work.
Hope this helps though, please do let me know if you find a better way, but I'm dealing with a javascript/ajax page I don't have access to, so this was a stretch of the imagination.
public partial class WasteTime : Form
{
static System.Windows.Forms.Timer timmer = new System.Windows.Forms.Timer();
public WasteTime()
{
InitializeComponent();
}
private void WasteTime_Load(object sender, EventArgs e)
{
int inter = 1200; //1.2 secs
timmer.Tick+=new EventHandler(timmer_Tick);
timmer.Interval = inter;
timmer.Start();
}
private void timmer_Tick(object obj, EventArgs e)
{
this.Close();
timmer.Stop();
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|