Reputation: 432
First of all I've repaired WebBrowser and now I see the page correctly in my Windows Form. I folowed this link and referenced it to IE 11.0 so the WebBrowser control in my windows form is a IE11.0 browser instance.
I have this in the constructor of the form:
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
then the event handler
public void WebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
txtLoad.Text = (Convert.ToInt32((txtLoad.Text)) + 1).ToString();
var webBrowser = sender as WebBrowser;
webBrowser.Document.GetElementById("gwt-uid-126").InvokeMember("click");
}
It all starts with a click of a button :
void BtnTestClick(object sender, EventArgs e)
{
webBrowser1.Navigate(@"https://play.google.com/apps/publish/?dev_acc=06010154238306490792#AppListPlace");
}
The click invoke does nothing . I tried all methods listed here and nothing. Why can I see the button on my screen but cannot reference it in code? Why is documentCompleted firing if the button didn't load already? How can I get the button? and click it?
Upvotes: 0
Views: 2105
Reputation: 56
Fix:
webBrowser1.Navigate(@"https://play.google.com/apps/publish/?dev_acc=06010154238306490792#AppListPlace");
while (WebBrowser1.ReadyState != WebBrowserReadyState.Complete) {
txtLoad.Text = WebBrowser1.ReadyState.ToString();
Application.DoEvents();
System.Threading.Thread.Sleep(1);
}
webBrowser1.Document.GetElementById("gwt-uid-126").InvokeMember("click");
there i a call to the WebBrowserDocumentCompleted event even if the document is not fully loaded.
example:
lets say that there are 2 script elements inside the page source code:
<script src="1.js"></script>
//Here There Is A Call To WebBrowserDocumentCompleted
<script src="2.js"></script>
//Here There Is A Call To WebBrowserDocumentCompleted
............
body
.............
</html>
//Here There Is A Call To WebBrowserDocumentCompleted
the webbrowser is calling this event even after he done loading script/stylesheet - the page is not really fully loaded yet.
Upvotes: 3