DOM problem with new internet explorer window

S

SQACSharp

Ok i try to automate IE with the DOM, i usually do this with VB but i
need to integrate it to my C# application. Here is an example :


using mshtml;
using SHDocVw;

....

SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorerClass();
SHDocVw.IWebBrowserApp ObjBrowser = (SHDocVw.IWebBrowserApp)ie;
ObjBrowser.Visible = true;
object noValue = System.Reflection.Missing.Value;
object noValue1 = System.Reflection.Missing.Value;
ie.Navigate("http://www,blablabla.com", ref noValue, ref noValue, ref
noValue, ref noValue);
WaitForReadyState(); 'Not included in this example
HTMLDocument document = ((HTMLDocument)ie.Document);
HTMLInputElement button =
(HTMLInputElement)document.getElementById("MyButtonId");
button.click(); // This close the current win and open a new one
WaitForReadyState();
// Missing magick here to access to the DOM of the new windows //
MessageBox.Show(document.body.innerHTML);

I dont know how i can catch the new windows and being able to declare
it as a browser object.

I can do it with VB with the following code but i cant find the C#
equivalent :(

Set ObjBrowser = CreateObject("InternetExplorer.Application")
ObjBrowser.Visible = TRUE
ObjBrowser.Navigate("http://www.blablabla.com")
WaitUntilPageIsLoaded
set ObjDocument = ObjBrowser.document
ObjDocument.GetElementById("MyButtonId").Click
WaitUntilPageIsLoaded
Set AllIE = CreateObject("Shell.Application")
dim x
for x=0 to AllIE.windows.Count-1
if inStr(AllIE.windows(x).locationUrl,"TheExpectedPage.asp")>0
then
'msgbox "found = "+AllIE.windows(x).locationUrl
exit for
end if
next x
set ObjBrowser=AllIE.windows(x) '** HOW TO DO THIS WITH C# ???
****
set ObjDocument = ObjBrowser.document ** HOW TO DO THIS WITH
C# ??? ****
msgbox ObjDocument.body.innerHtml

Any help, clues or examples?? I'm trying to figure how to do this
since hours.... I play with System.Diagnostics.Process.GetProcesses()
but I really dont know how to convert it to a usable browser object.

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top