WebBrowser Control - events etc

  • Thread starter Thread starter Oliver
  • Start date Start date
O

Oliver

hi -
- I'm trying to write a test tool that will automatically browse web
pages, and do simple assertions etc.

I'm struggling with the Web Browser control and mshtml -

1) if I try and capture click events (or any event) - like this:

document = (mshtml.HTMLDocument) ie.Document;
mshtml.HTMLDocumentEvents2_Event eventsDoc;
eventsDoc = (mshtml.HTMLDocumentEvents2_Event) document;
eventsDoc.onclick += new
HTMLDocumentEvents2_onclickEventHandler(eventsDoc_onclick);

it works! - click events are handled. However I find that in can't
type text into the text boxes in the browser, and buttons don't
animate... hmmm

anyone got any idea what's happening? - I guessed (struggling with
documentation on all this) that I just needed to set the
eventsArgs.cancelBubble property and/or the boolean return value...
but no

in fact - the odd behaviour happens without the event firing - just
the affect of wiring it in screws things up....

2) does it sound feasible to record the sequence of a users actions -
in such a way as to play them back at leisure ? - I thought this would
be a good basis for an auto-testing tool..

thanks all,
Oliver.
 
I'm struggling with the Web Browser control and mshtml -

1) if I try and capture click events (or any event) - like this:
it works! - click events are handled. However I find that in can't
type text into the text boxes in the browser, and buttons don't
animate... hmmm

It's a well-known bug. The workaround is to implement HtmlDocumentEvents2 in
your application - search Google for Jim Allison's post in this newsgroup.

You might also be interested in the solutions here:

http://www.itwriting.com/htmleditor/index.php

which takes another approach to catching the events; or in fact you can
combine the two approaches.

Tim
 
Hi Oliver,

The problem could be because you are using the Documnet
event(HTMLDocumentEvents2_Event)class to handle the click
events.This causes focus of whole document towards the event you are
handling with this event class and disables the access to Web document
loaded on the Browser control. Try using HTMLButtonElementEvents2_Event
class instead, in the following similar way you have been using
HTMLDocumentEvents2_Event class :

((HTMLButtonElementEvents2_Event)button).onclick += new
HTMLButtonElementEvents2_onclickEventHandler(button_click_handler_FuncNa
me);

this retains the access to the web page loaded on the web browser
control editor.

Regards,
Tanveer
 
Back
Top