Firefox-Marionette

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    In addition, this method will accept a hash of values as parameters as
    well. When a hash is provided, this method will alter specific parts of
    the normal Firefox User Agent. These hash parameters are;

      * os - The desired operating system, known values are "linux",
      "win32", "darwin", "freebsd", "netbsd", "openbsd" and "dragonfly"

      * version - A specific version of firefox, such as 120.

      * arch - A specific version of the architecture, such as "x86_64" or
      "aarch64" or "s390x".

      * increment - A specific offset from the actual version of firefox,
      such as -5

    These parameters can be used to set a user agent string like so;

        use Firefox::Marionette();
        use strict;
    
        my $firefox = Firefox::Marionette->new();
        $firefox->agent(os => 'freebsd', version => 118);
    
        # user agent is now equal to
        # Mozilla/5.0 (X11; FreeBSD amd64; rv:109.0) Gecko/20100101 Firefox/118.0
    
        $firefox->agent(os => 'linux', arch => 's390x', version => 115);
        # user agent is now equal to
        # Mozilla/5.0 (X11; Linux s390x; rv:109.0) Gecko/20100101 Firefox/115.0

    If the stealth parameter has supplied to the new method, it will also
    attempt to create known specific javascript functions to imitate the
    required browser. If the database built by build-bcd-for-firefox
    <https://metacpan.org/pod/build-bcd-for-firefox> is accessible, then it
    will also attempt to delete/provide dummy implementations for the
    corresponding javascript attributes
    <https://github.com/mdn/browser-compat-data> for the desired browser.
    The following websites have been very useful in testing these ideas;

      * https://browserleaks.com/javascript

      * https://www.amiunique.org/fingerprint

      * https://bot.sannysoft.com/

      * https://lraj22.github.io/browserfeatcl/

    Importantly, this will break feature detection
    <https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/Feature_detection>
    for any website that relies on it.

    See IMITATING OTHER BROWSERS a discussion of these types of techniques.
    These changes are not foolproof, but it is interesting to see what can
    be done with modern browsers. All this behaviour should be regarded as
    extremely experimental and subject to change. Feedback welcome.

 alert_text

    Returns the message shown in a currently displayed modal message box

 alive

    This method returns true or false depending on if the Firefox process
    is still running.

 application_type

    returns the application type for the Marionette protocol. Should be
    'gecko'.

 arch

    returns the architecture of the machine running firefox. Should be
    something like 'x86_64' or 'arm'. This is only intended for test suite
    support.

 aria_label

    accepts an element as the parameter. It returns the ARIA label
    <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label>
    for the element.

 aria_role

    accepts an element as the parameter. It returns the ARIA role
    <https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles>
    for the element.

 async_script

    accepts a scalar containing a javascript function that is executed in
    the browser. This method returns itself to aid in chaining methods.

    The executing javascript is subject to the script timeout, which, by
    default is 30 seconds.

 attribute

    accepts an element as the first parameter and a scalar attribute name
    as the second parameter. It returns the initial value of the attribute
    with the supplied name. This method will return the initial content
    from the HTML source code, the property method will return the current
    content.

        use Firefox::Marionette();
    
        my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/');
        my $element = $firefox->find_id('metacpan_search-input');
        !defined $element->attribute('value') or die "attribute is defined but did not exist in the html source!";
        $element->type('Test::More');
        !defined $element->attribute('value') or die "attribute has changed but only the property should have changed!";

 await

    accepts a subroutine reference as a parameter and then executes the
    subroutine. If a not found exception is thrown, this method will sleep
    for sleep_time_in_ms milliseconds and then execute the subroutine
    again. When the subroutine executes successfully, it will return what
    the subroutine returns.

        use Firefox::Marionette();



( run in 0.984 second using v1.01-cache-2.11-cpan-5a3173703d6 )