Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How to get DOM from currently open IE browser.

by technojosh (Priest)
on Nov 07, 2007 at 11:36 UTC ( #649459=note: print w/ replies, xml ) Need Help??


in reply to How to get DOM from currently open IE browser.

Since you:

use Win32::GuiTest qw(:ALL);

take a look at its methods:

FindWindowLike(); SetActiveWindow(); SetForegroundWindow();

CPAN Link

The above link has much better examples, but in a nutshell 'FindWindowLike' will find the IE window by name (among other things), and give you its ID (among other things). You can use that with 'SetActiveWindow' in combination with 'SetForegroundWindow' to grab your IE window and give it focus.


Comment on Re: How to get DOM from currently open IE browser.
Select or Download Code
Re^2: How to get DOM from currently open IE browser.
by dadto7 (Novice) on Nov 07, 2007 at 15:23 UTC
    Thanks for your reply and the link is great. I've used some of that before where I can get things from various windows and use the Clipboard to manipulate the data.

    Unfortunately, I do not see how this can help be get things out of the HTML/DOM. Let's say I want to get the value from a SPAN id named "Errorcnt". In JavaScript it would look something like "document.getElementById('Errorcnt').innerHTML". This is why I feel that I'll have to use the Win32::OLE package stuff.

    Did you have a Win32:GuiTest method in mind that would do that?

    THX, Nick.

      I saw some examples on the web but they all seem to open new IE windows and that does not help me. I need to get to windows that are already open.

      My suggestions were for your above issue, those methods I mentioned would help to get you to an IE window that is already open...I apologize if I misread your question.

        Sorry, maybe I misunderstood what methods you meant. I have used the Win23::GuiTest methods to successfully get the window active/foreground. You can get some rudimentary info like URL, and Window title using the examples I've seen on the net. But no examples I've seen get the innerHTML (See the JavaScript sample in my previous reply to see the type of data I hope to retrieve). A Win32::OLE example would look like below. But the GetActiveObject does not seem to work and that is my real problem.
        my $currDir = cwd; my $url = "file://" . $currDir . "/osmerrors1.html?5,now"; my $IE; $IE = Win32::OLE->GetActiveObject( "InternetExplorer.Application" ); $IE->Navigate($url , 4 ); my $IEurl = $IE->Document->URL;

        But I have not seen any examples yet where you can get to the HTML which is what I need. That is why I asked for the specific method you think will do that and I can try those.

        BTW, you may have noticed this is my first question here so I need to figure out how you got the stuff in italics at the beginning of you last reply. Did you just cut and paste that and surround it with the "code" stuff?

        THX, Nick

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://649459]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-07-25 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (174 votes), past polls