After re-implementing this by hand about a dozen times now, I've created a package to deal with it in a single method call. Win32::WebBrowser exports a single method, open_browser(), that pops open the default browser in a detached process and points it at a URL.
Any chance that you can add more tests? One that tries to call open_browser with 'about:blank' (which works in IE, Firefox and presumably any modern browser. Perhaps ship an HTML file in t/ that could be loaded with open_browser in yet another test.
# 02about_blank.t use Test::More tests => 1; use Win32::WebBrowser;
BEGIN { unless ($^O eq 'MSWin32') { skip('This package is for Microsoft Windows platforms only.'); exit; } }
I considered it, but it has side-effects, namely,
its going to pop open a browser that can't be closed
except by hand. My general impression has been that those sorts of test side effects are frowned upon.
So I just did a load test, and made sure it worked
on IE, Firefox, and Opera before shipping.
There is an examples/google.pl that can be exersized by the more QA conscientious.
Sounds like you need to add close_browser() then.:)
If you chose to do so, it shouldn't be too difficult since you are already using Win32::Process. For the automated tests, you'd want to have the ability to know if open_browser reused a browser window (FF for example will just add a tab if it's already running when you call open_browser) so that you'd know whether or not to close it.
Sounds like you need to add close_browser() then.:)
Slippery slope, that (including your note wrt Firefox). My intent was more in the spirit of my favorite Perlism: "Simple things should be easy".
Opening a browser using Perl on Windows seems simple, and should be easy, but wasn't.
My comment was mostly in jest. ("Mostly" because if you're going to go to the trouble of making it easy to open a browser in Perl then why not go the extra step and make it just as easy to close it when you are done?)
To be honest, there has only been one or two times that I've wanted to open a browser with Perl. I think I used a system call to 'start URL' and found the window with Win32::GUITest so that I could close it when I was finished.
I had no idea it existed, and yes I have searched CPAN numerous times. It might have been helpful if the name included "Browser" or "WebBrowser" or somesuch.
That said, I will keep it in my toolbox for future *nix platform efforts (tho I wonder how effective it is there, given the lack of a formal standard for locating the default browser on such platforms. If you're lucky, $ENV{BROWSER} exists, but beyond that, it
Finding modules >IS hard. It would be nice to upgrade HTML::Display so it comes up as a hit to your searches- though I do not know what is the right way.
You are right, they say Win32 does not work, I forgot that.
Maybe you two authors should get together. Max is cool. Maybe you can cross reference each others documentation to each others modules, or combine in one namespace.
Since you're talking about Corion [perlmonks.org], let me tell you this: he's a very experienced user of Windows. So if he can't get HTML::Display to work on Windows, you may be pretty sure there must be a very good reason for it.
More Tests? (Score:2)
Any chance that you can add more tests? One that tries to call open_browser with 'about:blank' (which works in IE, Firefox and presumably any modern browser. Perhaps ship an HTML file in t/ that could be loaded with open_browser in yet another test.
Re: (Score:1)
So I just did a load test, and made sure it worked on IE, Firefox, and Opera before shipping.
There is an examples/google.pl that can be exersized by the more QA conscientious.
Re: (Score:1)
Re: (Score:2)
Sounds like you need to add close_browser() then. :)
If you chose to do so, it shouldn't be too difficult since you are already using Win32::Process. For the automated tests, you'd want to have the ability to know if open_browser reused a browser window (FF for example will just add a tab if it's already running when you call open_browser) so that you'd know whether or not to close it.
Just a thought...
Re: (Score:1)
Slippery slope, that (including your note wrt Firefox). My intent was more in the spirit of my favorite Perlism: "Simple things should be easy". Opening a browser using Perl on Windows seems simple, and should be easy, but wasn't.
Now it is.
Re: (Score:2)
My comment was mostly in jest. ("Mostly" because if you're going to go to the trouble of making it easy to open a browser in Perl then why not go the extra step and make it just as easy to close it when you are done?)
To be honest, there has only been one or two times that I've wanted to open a browser with Perl. I think I used a system call to 'start URL' and found the window with Win32::GUITest so that I could close it when I was finished.
HTML::Display (Score:1)
Why stop at Win32?
HTML::Display display HTML locally in a browser
HTML::Display::Common routines common to all HTML::Display subclasses
HTML::Display::Debian display HTML using the Debian default
HTML::Display::Dump dump raw HTML to the console
HTML::Display::Galeon display HTML through Galeon
HTML::Display::Mozilla display HTML through Mozilla
HTML::Display::OSX display HTML on OSX
HTML::Display::Opera
HTML::Display:
Re: (Score:1)
That said, I will keep it in my toolbox for future *nix platform efforts (tho I wonder how effective it is there, given the lack of a formal standard for locating the default browser on such platforms. If you're lucky, $ENV{BROWSER} exists, but beyond that, it
Re: (Score:1)
You are right, they say Win32 does not work, I forgot that.
Maybe you two authors should get together. Max is cool. Maybe you can cross reference each others documentation to each others modules, or combine in one namespace.
Re: (Score:2)