I am trying to navigate to a page with a hidden browser from within a C# application, click on a link and verify the click worked.
Flow:
- navigate to "http://mypage"
- click on a link, the link HTML code is (calling a ComponentArt CallBack):
<div id="ctl00_ctl00_PlaceHolderMain_Colleague1_linkAdd" onclick="colleagueCallback.callback('SOMENAME'); return false;">
<a href="javascript:void(0)">Add colleague</a>
</div>
- wait for the click to get the result and update the page
- verify the click worked
My problem:
The click does not seem to fully complete, unless I call the WebBroser.Print() (which I do not need, just tried a million ways to figure out what is going on after the click, only Print is making the click complete).
The code, which works absolutely fine, navigate is working, it can find the tags I am looking for, the click event is firing (I get an intermediary change), but the callback does not complete, as it turns out only using the WebBrowser.Print(), all the other WebBrowser.Invalidate(), WebBrowser.Update(), WebBrowser.DocumentStream.Flush() or WebBroser.ResumeLayout() won't finalize the ASP callback within the page ...:
tempIE = new WebBrowser();
tempIE.Navigate("http://mypage");
while (tempIE.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
tempIE.AllowNavigation = true;
HtmlElement addDivTag = tempIE.Document.GetElementById("ctl00_ctl00_PlaceHolderMain_Colleague1_linkAdd");
if (addDivTag == null)
throw (new Exception("Session.FollowPerson: could not find the Add tag"));
if ( addDivTag.FirstChild == null )
throw (new Exception("Session.FollowPerson: could not find the add link"));
addDivTag.FirstChild.InvokeMember("click");
while (tempIE.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
After this I am verifying if one of the tags has been changed by the ComponentArt server CallBack but only getting the intermediary tag. The change I am monitoring is:
<a href="javascript:void(0)">Add colleague</a>
will change intermediary to (while making the add logic in the CallBack):
<img src="/images/loading.gif">
in the end should change to:
<br>Is your colleague</br>
Anyone knows what exaclty is going on in the WebBroser.Print() that makes the page fully complete the callback ?