c# - Awesomium .NET: Document is not ready in DocumentReady event? -


i using awesomium 1.7.0.5 in order load page, fill textboxes , click button. trying fill textbox using example thread: http://answers.awesomium.com/questions/857/webcontrol-type-in-webbrowser.html

here code (i using wpf control):

        private void wbawsondocumentready(object sender, urleventargs urleventargs)         {             if (wbaws == null || !wbaws.islive)               return;              //thread.sleep(555);              dynamic document = (jsobject)wbaws.executejavascriptwithresult("document");              if (document == null)               return;              using (document)             {                 dynamic textbox = document.getelementbyid("email");                  if (textbox == null)                   return;                  using (textbox)                 {                     textbox.value = "gaaffa";                  }              }         } 

it works thread.sleep 0.1-0.5 sec. otherwise document empty (not null) and/or textbox null. should do? why not ready in documentreadyevent?

here how solved it:

     wbaws.loadingframecompleted += onloadingframecompleted;      wbaws.source = new uri("http://google.com");  private void onloadingframecompleted(...) {     if (webview == null || !webview.islive ||           webview.parentview != null || !e.ismainframe)      return;      loadingframecompleted -= onloadingframecompleted;      // } 

loadingframecompleted instead of documentready , because fires not when need on app startup subscribe before navigating , unsubscribe after it. checking ismainframe.

edit: solution throws exception document not ready. waiting using thread.sleep.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -