|
NAMEFirefox::Marionette::Element - Represents a Firefox element retrieved using the Marionette protocolVERSIONVersion 1.17SYNOPSISuse Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $element = $firefox->find('//input[@id="search-input"]'); $element->type('Test::More'); DESCRIPTIONThis module handles the implementation of a Firefox Element using the Marionette protocolSUBROUTINES/METHODSattributeaccepts a scalar name a parameter. It returns the initial value of the attribute with the supplied name. Compare with the current value returned by property method.browserreturns the browser connected with the element.clearclears any user supplied input from the elementclicksends a 'click' to the element. The browser will wait for any page load to complete or the session's page_load duration to elapse before returning, which, by default is 5 minutes. The click method is also used to choose an option in a select dropdown.use Firefox::Marionette(); my $firefox = Firefox::Marionette->new(visible => 1)->go('https://ebay.com'); my $select = $firefox->find_tag('select'); foreach my $option ($select->find_tag('option')) { if ($option->property('value') == 58058) { # Computers/Tablets & Networking $option->click(); } } cssaccepts a scalar CSS property name as a parameter. It returns the value of the computed style for that property.findaccepts an xpath expression <https://en.wikipedia.org/wiki/XPath> expression> as the first parameter and returns the first element that matches this expression.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); $div->find('//input[@id="search-input"]')->type('Test::More'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find('//input[@id="search-input"]')) { $element->type('Test::More'); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has method. find_idaccepts an id <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id> as the first parameter and returns the first element with a matching 'id' property.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); $div->find_id('search-input')->type('Test::More'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find_id('search-input')) { $element->type('Test::More'); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_id method. find_nameThis method returns the first element with a matching 'name' property.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); $div->find_name('q')->type('Test::More'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find_name('q')) { $element->type('Test::More'); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_name method. find_classaccepts a class name <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class> as the first parameter and returns the first element with a matching 'class' property.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); $div->find_class('form-control home-search-input')->type('Test::More'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find_class('form-control home-search-input')) { $element->type('Test::More'); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_class method. find_selectoraccepts a CSS Selector <https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors> as the first parameter and returns the first element that matches that selector.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); $div->find_selector('input.home-search-input')->type('Test::More'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find_selector('input.home-search-input')) { $element->type('Test::More'); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_selector method. find_tagaccepts a tag name <https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName> as the first parameter and returns the first element with this tag name.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); my $input = $div->find_tag('input'); # OR in list context my $div = $firefox->find_class('main-content'); foreach my $element ($div->find_tag('input')) { # do something } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_tag method. find_linkaccepts a text string as the first parameter and returns the first link element that has a matching link text.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('container-fluid'); $div->find_link('API')->click(); # OR in list context my $div = $firefox->find_class('container-fluid'); foreach my $element ($div->find_link('API')) { $element->click(); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_link method. find_partialaccepts a text string as the first parameter and returns the first link element that has a partially matching link text.This method is subject to the implicit timeout. use Firefox::Marionette(); use v5.10; my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('container-fluid'); $div->find_partial('AP')->click(); # OR in list context my $div = $firefox->find_class('container-fluid'); foreach my $element ($div->find_partial('AP')) { $element->click(); } If no elements are found, a not found exception will be thrown. For the same functionality that returns undef if no elements are found, see the has_partial method. hasaccepts an xpath expression <https://en.wikipedia.org/wiki/XPath> as the first parameter and returns the first element that matches this expression.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has('//input[@id="search-input"]')) { $element->type('Test::More'); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find method. has_idaccepts an id <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id> as the first parameter and returns the first element with a matching 'id' property.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has_id('search-input')) { $element->type('Test::More'); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_id method. has_nameThis method returns the first element with a matching 'name' property.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has_name('q')) { $element->type('Test::More'); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_name method. has_classaccepts a class name <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class> as the first parameter and returns the first element with a matching 'class' property.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has_class('form-control home-search-input')) { $element->type('Test::More'); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_class method. has_selectoraccepts a CSS Selector <https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors> as the first parameter and returns the first element that matches that selector.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has_selector('input.home-search-input')) { $element->type('Test::More'); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_selector method. has_tagaccepts a tag name <https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName> as the first parameter and returns the first element with this tag name.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('main-content'); if (my $element = $div->has_tag('input'); # do something } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_tag method. has_linkaccepts a text string as the first parameter and returns the first link element that has a matching link text.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('container-fluid'); if (my $element = $div->has_link('API')->click(); $element->click(); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_link method. has_partialaccepts a text string as the first parameter and returns the first link element that has a partially matching link text.This method is subject to the implicit timeout, which, by default is 0 seconds. use Firefox::Marionette(); my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); my $div = $firefox->find_class('container-fluid'); if (my $element = $div->has_partial('AP')->click(); $element->click(); } If no elements are found, this method will return undef. For the same functionality that throws a not found exception, see the find_partial method. is_enabledreturns true or false if the element is enabled.is_selectedreturns true or false if the element is selected.is_displayedreturns true or false if the element is displayed.newreturns a new element.propertyaccepts a scalar name a parameter. It returns the current value of the property with the supplied name. Compare with the initial value returned by attribute method.rectreturns the current position and size of the elementsend_keys*** DEPRECATED - see type. ***selfiereturns a File::Temp object containing a lossless PNG image screenshot of the element.accepts the following optional parameters as a hash;
switch_to_frameswitches to this frame within the current window.switch_to_shadow_rootswitches to this element's shadow root <https://www.w3.org/TR/shadow-dom/>tag_namereturns the relevant tag name. For example 'a' or 'input'.textreturns the text that is contained by that element (if any)typeaccepts a scalar string as a parameter. It sends the string to this element, such as filling out a text box. This method returns the browser to aid in chaining methods.uuidreturns the browser generated UUID connected with this element.DIAGNOSTICSNone.CONFIGURATION AND ENVIRONMENTFirefox::Marionette::Element requires no configuration files or environment variables.DEPENDENCIESNone.INCOMPATIBILITIESNone reported.BUGS AND LIMITATIONSTo report a bug, or view the current list of bugs, please visit <https://github.com/david-dick/firefox-marionette/issues>AUTHORDavid Dick "<ddick@cpan.org>"LICENSE AND COPYRIGHTCopyright (c) 2021, David Dick "<ddick@cpan.org>". All rights reserved.This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See "perlartistic" in perlartistic. DISCLAIMER OF WARRANTYBECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Visit the GSP FreeBSD Man Page Interface. |