Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I work on a large web application which needs lots of UI tests. It uses javascript in places. I started out by subclassing WWW::Mechanize and just emulating the javascript parts, but it gets annoying after a while, not to mention I'd like something more general anyway. So a few weeks ago, I set out on a quest for a way to parse javascript in HTML using Perl.

In fact, I've been asking around, so my apologies if you've heard this story already.

At first, I thought about adding javascript support to WWW::Mechanize using JavaScript::SpiderMonkey. It sounds nice in principle, because JS::SM is the javascript interpreter used by Mozilla. However, in fact it's only the raw interpreter, lacking any browser objects (window, document, etc.) or DOM initialization. After looking at several W3 specifications and HTML::TreeBuilder, I decided to pass on trying to implement the DOM myself.

Next, I found Win32::IE::Mechanize. This uses OLE to control Internet Explorer, and it emulates the WWW::Mechanize interface as a bonus. The only problem is it requires Microsoft® Windows®. Actually, I don't mind Windows so much, but Bricolage doesn't run on Windows so I couldn't test it on my laptop at home.

Trying to find an analogous approach on Linux, I thought of using DCOP with Konqueror, or KHTML. But I couldn't find enough documentation to do useful things (get a handle on the DOM, to click on buttons and links, select from dropdown menus, etc.). If anyone has any pointers/guidance along these lines, it would be much appreciated.

Then I thought again of using Mozilla. This time I had found Gtk2::MozEmbed, which is another great Perl module (the Gtk-Perl documentation and mailing list are fantastic). You can actually embed a Mozilla browser inside a Gtk2 application using Perl. However, it lacks support for things I need (get a handle on the DOM, to click on buttons and links, select from dropdown menus, etc.).

Finally, I found Perl XPCOM, which was yet another very promising path. These are Perl bindings to XPCOM, which are kind of the equivalent of OLE for Mozilla. The problem is, I couldn't get it to build, and the project seems dead (xpcom; the mailing list seems to no longer exist). To be honest, I'm not even sure how I'd proceed once I got XPCOM access, since the documentation I find seems to generally be either about creating XPCOM components in whatever language or is so general or abstract that I don't understand its usefulness.

So then.. I was wondering if anyone had found something. Actually, by this point, I'm not sure I even care whether it uses Perl, as long as I can script interaction with a web application.

UPDATE: I found this discussion. The point Perrin makes is interesting. I have to think about it more, though. I'm not sure if creating tests several pages deep into the interface would work well or not.

UPDATE 2: After noticing an update in the "What's New?" section of the plxpcom site, I built plxpcom in Mozilla 1.6 and it seems to work. I would like to find the "community" for this project, because apparently other than doing `cvs update` every day, there isn't much interaction with the person/people maintaining the project. From a discussion at use.perl.org, I know there are at least one or two others interested in the project.

UPDATE 3 (Aug 5, 2005): See Mozilla::DOM


In reply to How can I test a javascript-enhanced web application on Linux? by ForgotPasswordAgain

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-19 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found