|Do you know where your variables are?|
Whatever happened to Win32::IE::Mechanize?by Michael Roberts (Sexton)
|on Nov 05, 2013 at 23:13 UTC||Need Help??|
Michael Roberts has asked for the wisdom of the Perl Monks concerning the following question:
So sue me, maybe I'm just old, but I have a need to automate some browser-oriented stuff on Windows, I need to be able to pass the browser over to the user, and I just can't figure out how Selenium is supposed to work for me.
I turned to a tool I'd been intending to try out for years - Win32::IE::Mechanize - and to my utter surprise, found it is gone from CPAN!
Granted, it hadn't been updated since 2005 (really? it seems like yesterday...) but ... isn't it odd? Can it really be the case that I'm the only person in the world who intended to do something with IE one of these days? Because actually, OLE is kind of neat.
I've emailed Abe Timmerman, because I wouldn't mind adopting the module, but to no avail. Does anybody know about the considerations leading up to this decision? Because if there's some showstopping reason it just can't work any more, then I don't want to mess with it, but honestly, I'd like to maybe spruce it up a little and get it back onto CPAN.
Technically, I guess there's nothing stopping me from just uploading a new version given it's no longer there - but that seems really, um, is chutzpah-y a word? It just doesn't seem very polite.
What does the collective wisdom of the Monks dictate?Update:
Now I see why Abe dropped the module entirely. In IE8, Microsoft did something very, very stupid, which effectively breaks OLE automation for IE, to wit: when you open up a new IE browser instance, IE assumes it will be running in Low Integrity Level, going out to the Internet. But if you retrieve a local page, that's Intranet, not Internet - and it's Medium Integrity Level. A single process can't change integrity levels. So IE invisibly opens a new tab in a new process and swaps it out.
That means the original one is defunct now. IE passes you a NewProcess event that can be trapped - but it doesn't contain a reference to a new OLE automation object or even the automation interface. It just contains, as far as I can tell, a scalar PID which - through some magickal Win32 manipulation - could possibly maybe perhaps be persuaded to yield a new OLE interface. Just one problem: I have no freaking clue at all how to do that, and apparently neither does anybody else I've found yet.
The Selenium team seems to have solved it in C++ for their IEDriver. That stuff is utterly impenetrable on first and second readings. That Microsofty interface junk is why I switched to Perl in the 90's in the first place, and I really didn't want to go back there.
So there are two things I could do. I could run all testing with a local microserver instance, which would be a quick and dirty solution. Or I could man up, figure out this Wininternals stuff, and get it into CPAN.
There's an MSDN article touching on the background for this. What to do about it is left as an exercise for the reader.Update:
Holy Toledo. Put a MOTW (Mark of the Web, Google it) comment into a local file and IE will treat it as though it had come from the Protected Mode zone. You can re-zone any web content into a more restricted zone with the MOTW hack.
I've also found various stuff here that is tantalizingly close to what I need to do this right: this node for instance. I can't really figure out how to call CreatePerlObject from Perl - what are those parameters?!?
I've managed to figure out how to start a Medium IL Internet Explorer instance that can work with local files but not with remote ones (i.e. the same phenomenon in reverse). I think I've found the right interface to determine the zone of a given URL, but calling it looks daunting - Windows and Perl still don't really get along all that well.
This is getting pretty freaking interesting. But I don't have time for this! All I wanted to do was just automate Internet Explorer...Update:
... Wait. MOTW fixes the problems with the test suite for IEMech.
OK, that's it. Win32::IE::Mechanize will be back on CPAN this week. I think I've earned it after losing a day and a half to this freaking mess Microsoft hath wrought. (I actually understand (kind of) where they're coming from - the security model is well considered and works for the userbase they have to make it work for - but did they really have to break Automation?)