Max Maischein > WWW-Mechanize-Firefox-0.74 > Firefox::Application

Download:
WWW-Mechanize-Firefox-0.74.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  1
View/Report Bugs
Module Version: 0.74   Source   Latest Release: WWW-Mechanize-Firefox-0.78

NAME ^

Firefox::Application - inspect and automate the Firefox UI

SYNOPSIS ^

  use Firefox::Application;
  my $ff = Firefox::Application->new();

This module will let you automate Firefox through the Mozrepl plugin. You need to have installed that plugin in your Firefox.

For more examples see WWW::Mechanize::Firefox::Examples.

METHODS ^

Firefox::Application->new( %args )

  use Firefox::Application;
  my $ff = Firefox::Application->new();

Creates a new instance and connects it to Firefox.

Note that Firefox must have the mozrepl extension installed and enabled.

The following options are recognized:

$ff->repl

  my ($value,$type) = $ff->repl->expr('2+2');

Gets the MozRepl::RemoteObject instance that is used.

APPLICATION INFORMATION ^

$ff->appinfo

    my $info = $ff->appinfo;
    print 'ID      : ', $info->{ID};
    print 'name    : ', $info->{name};
    print 'version : ', $info->{version};

Returns information about Firefox.

$ff->addons( %args )

  for my $addon ($ff->addons) {
      print sprintf "Name: %s\n", $addon->{name};
      print sprintf "Version: %s\n", $addon->{version};
      print sprintf "GUID: %s\n", $addon->{id};
  };

Returns the list of installed addons as nsIUpdateItems (FF 3.5+) or Addons (FF4+). See https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIUpdateItem or https://developer.mozilla.org/en/Addons/Add-on_Manager/Addon, depending on your Firefox version.

$ff->locales( %args )

  for my $locale ($ff->locales) {
      print sprintf "Name: %s\n", $locale->{name};
      print sprintf "Version: %s\n", $locale->{version};
      print sprintf "GUID: %s\n", $locale->{id};
  };

Returns the list of installed locales as nsIUpdateItems.

$ff->themes( %args )

  for my $theme ($ff->themes) {
      print sprintf "Name: %s\n", $theme->{name};
      print sprintf "Version: %s\n", $theme->{version};
      print sprintf "GUID: %s\n", $theme->{id};
  };

Returns the list of installed locales as nsIUpdateItems.

$ff->updateitems( %args )

  for my $item ($ff->updateitems) {
      print sprintf "Name: %s\n", $item->{name};
      print sprintf "Version: %s\n", $item->{version};
      print sprintf "GUID: %s\n", $item->{id};
  };

Returns the list of updateable items. The type of item can be restricted by the type option.

$ff->current_profile

    print $ff->current_profile->{name}, "\n";

Returns currently selected profile as nsIToolkitProfile.

See https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIToolkitProfile.

$ff->find_profile( $name )

    print $ff->find_profile("")->{localDir}, "\n";

Returns the profile given its name. Dies if the profile cannot be found.

$ff->profiles

    for ($ff->profiles) {
        print "Profile: ", $_->{name}, "\n";
    }

Lists the installed profiles as nsIToolkitProfiles.

See https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIToolkitProfile.

UI METHODS ^

$ff->addTab( %options )

    my $new = $ff->addTab();

Creates a new tab and returns it. The tab will be automatically closed upon program exit.

If you want the tab to remain open, pass a false value to the the autoclose option.

The recognized options are:

$ff->selectedTab( %options )

    my $curr = $ff->selectedTab();

Sets the currently active tab.

$ff->closeTab( $tab [,$repl] )

    $ff->closeTab( $tab );

Close the given tab.

$ff->openTabs( [$repl] )

    my @tab_info = $ff->openTabs();
    print "$_->{title}, $_->{location}, \n"
        for @tab_info;

Returns a list of information about the currently open tabs.

$ff->activateTab( [ $tab [, $repl ]] )

    $ff->activateTab( $mytab ); # bring to foreground

Activates the tab passed in.

$ff->browser( [$repl] )

    my $b = $ff->browser();

Returns the current Firefox browser instance, or opens a new browser window if none is available, and returns its browser instance.

If you need to call this as a class method, pass in the MozRepl::RemoteObject bridge to use.

$ff->getMostRecentWindow

Returns the most recently used Firefox window.

$ff->set_tab_content( $tab, $html [,$repl] )

    $ff->set_tab_content('<html><h1>Hello</h1></html>');

This is a more general method that allows you to replace the HTML of an arbitrary tab, and not only the tab that WWW::Mechanize::Firefox is associated with.

It has the flaw of not waiting until the tab has loaded.

$ff->quit( %options )

  $ff->quit( restart => 1 ); # restart
  $ff->quit(); # quit

Quits or restarts the application

TODO ^

AUTHOR ^

Max Maischein corion@cpan.org

COPYRIGHT (c) ^

Copyright 2009-2013 by Max Maischein corion@cpan.org.

LICENSE ^

This module is released under the same terms as Perl itself.

syntax highlighting: