1package Firefox::Marionette::Element; 2 3use strict; 4use warnings; 5 6our $VERSION = '1.10'; 7 8sub new { 9 my ( $class, $browser, %parameters ) = @_; 10 my $element = bless { 11 browser => $browser, 12 %parameters 13 }, $class; 14 foreach my $key ( sort { $a cmp $b } keys %parameters ) { 15 if ( $key =~ /^element/smx ) { 16 $element->{ELEMENT} = $parameters{$key}; 17 } 18 } 19 return $element; 20} 21 22sub TO_JSON { 23 my ($self) = @_; 24 my $json = {}; 25 foreach my $key ( sort { $a cmp $b } keys %{$self} ) { 26 if ( $key ne 'browser' ) { 27 $json->{$key} = $self->{$key}; 28 } 29 } 30 return $json; 31} 32 33sub uuid { 34 my ($self) = @_; 35 return $self->{ELEMENT}; 36} 37 38sub browser { 39 my ($self) = @_; 40 return $self->{browser}; 41} 42 43sub click { 44 my ($self) = @_; 45 return $self->browser()->click($self); 46} 47 48sub clear { 49 my ($self) = @_; 50 return $self->browser()->clear($self); 51} 52 53sub text { 54 my ($self) = @_; 55 return $self->browser()->text($self); 56} 57 58sub tag_name { 59 my ($self) = @_; 60 return $self->browser()->tag_name($self); 61} 62 63sub rect { 64 my ($self) = @_; 65 return $self->browser()->rect($self); 66} 67 68sub send_keys { 69 my ( $self, $text ) = @_; 70 Carp::carp( 71 '**** DEPRECATED METHOD - send_keys HAS BEEN REPLACED BY type ****'); 72 return $self->browser()->type( $self, $text ); 73} 74 75sub type { 76 my ( $self, $text ) = @_; 77 return $self->browser()->type( $self, $text ); 78} 79 80sub attribute { 81 my ( $self, $name ) = @_; 82 return $self->browser()->attribute( $self, $name ); 83} 84 85sub property { 86 my ( $self, $name ) = @_; 87 return $self->browser()->property( $self, $name ); 88} 89 90sub css { 91 my ( $self, $property_name ) = @_; 92 return $self->browser()->css( $self, $property_name ); 93} 94 95sub switch_to_frame { 96 my ($self) = @_; 97 return $self->browser()->switch_to_frame($self); 98} 99 100sub switch_to_shadow_root { 101 my ($self) = @_; 102 return $self->browser()->switch_to_shadow_root($self); 103} 104 105sub selfie { 106 my ( $self, %extra ) = @_; 107 return $self->browser()->selfie( $self, %extra ); 108} 109 110sub is_enabled { 111 my ($self) = @_; 112 return $self->browser()->is_enabled($self); 113} 114 115sub is_selected { 116 my ($self) = @_; 117 return $self->browser()->is_selected($self); 118} 119 120sub is_displayed { 121 my ($self) = @_; 122 return $self->browser()->is_displayed($self); 123} 124 125sub list { 126 my ( $self, $value, $using ) = @_; 127 Carp::carp( 128 '**** DEPRECATED METHOD - using list HAS BEEN REPLACED BY find ****'); 129 return $self->browser()->find( $value, $using, $self ); 130} 131 132sub list_by_id { 133 my ( $self, $value ) = @_; 134 Carp::carp( 135'**** DEPRECATED METHOD - using list_by_id HAS BEEN REPLACED BY find_id ****' 136 ); 137 return $self->browser()->find_id( $value, $self ); 138} 139 140sub list_by_name { 141 my ( $self, $value ) = @_; 142 Carp::carp( 143'**** DEPRECATED METHOD - using list_by_name HAS BEEN REPLACED BY find_name ****' 144 ); 145 return $self->browser()->find_name( $value, $self ); 146} 147 148sub list_by_tag { 149 my ( $self, $value ) = @_; 150 Carp::carp( 151'**** DEPRECATED METHOD - using list_by_tag HAS BEEN REPLACED BY find_tag ****' 152 ); 153 return $self->browser()->find_tag( $value, $self ); 154} 155 156sub list_by_class { 157 my ( $self, $value ) = @_; 158 Carp::carp( 159'**** DEPRECATED METHOD - using list_by_class HAS BEEN REPLACED BY find_class ****' 160 ); 161 return $self->browser()->find_class( $value, $self ); 162} 163 164sub list_by_selector { 165 my ( $self, $value ) = @_; 166 Carp::carp( 167'**** DEPRECATED METHOD - using list_by_selector HAS BEEN REPLACED BY find_selector ****' 168 ); 169 return $self->browser()->find_selector( $value, $self ); 170} 171 172sub list_by_link { 173 my ( $self, $value ) = @_; 174 Carp::carp( 175'**** DEPRECATED METHOD - using list_by_link HAS BEEN REPLACED BY find_link ****' 176 ); 177 return $self->browser()->find_link( $value, $self ); 178} 179 180sub list_by_partial { 181 my ( $self, $value ) = @_; 182 Carp::carp( 183'**** DEPRECATED METHOD - using list_by_partial HAS BEEN REPLACED BY find_partial ****' 184 ); 185 return $self->browser()->find_partial( $value, $self ); 186} 187 188sub find_by_id { 189 my ( $self, $value ) = @_; 190 Carp::carp( 191'**** DEPRECATED METHOD - using find_by_id HAS BEEN REPLACED BY find_id ****' 192 ); 193 return $self->browser()->find_id( $value, $self ); 194} 195 196sub find_by_name { 197 my ( $self, $value ) = @_; 198 Carp::carp( 199'**** DEPRECATED METHOD - using find_by_name HAS BEEN REPLACED BY find_name ****' 200 ); 201 return $self->browser()->find_name( $value, $self ); 202} 203 204sub find_by_tag { 205 my ( $self, $value ) = @_; 206 Carp::carp( 207'**** DEPRECATED METHOD - using find_by_tag HAS BEEN REPLACED BY find_tag ****' 208 ); 209 return $self->browser()->find_tag( $value, $self ); 210} 211 212sub find_by_class { 213 my ( $self, $value ) = @_; 214 Carp::carp( 215'**** DEPRECATED METHOD - using find_by_class HAS BEEN REPLACED BY find_class ****' 216 ); 217 return $self->browser()->find_class( $value, $self ); 218} 219 220sub find_by_selector { 221 my ( $self, $value ) = @_; 222 Carp::carp( 223'**** DEPRECATED METHOD - using find_by_selector HAS BEEN REPLACED BY find_selector ****' 224 ); 225 return $self->browser()->find_selector( $value, $self ); 226} 227 228sub find_by_link { 229 my ( $self, $value ) = @_; 230 Carp::carp( 231'**** DEPRECATED METHOD - using find_by_link HAS BEEN REPLACED BY find_link ****' 232 ); 233 return $self->browser()->find_link( $value, $self ); 234} 235 236sub find_by_partial { 237 my ( $self, $value ) = @_; 238 Carp::carp( 239'**** DEPRECATED METHOD - using find_by_partial HAS BEEN REPLACED BY find_partial ****' 240 ); 241 return $self->browser()->find_partial( $value, $self ); 242} 243 244sub find { 245 my ( $self, $value, $using ) = @_; 246 return $self->browser()->find( $value, $using, $self ); 247} 248 249sub find_id { 250 my ( $self, $value ) = @_; 251 return $self->browser()->find_id( $value, $self ); 252} 253 254sub find_name { 255 my ( $self, $value ) = @_; 256 return $self->browser()->find_name( $value, $self ); 257} 258 259sub find_tag { 260 my ( $self, $value ) = @_; 261 return $self->browser()->find_tag( $value, $self ); 262} 263 264sub find_class { 265 my ( $self, $value ) = @_; 266 return $self->browser()->find_class( $value, $self ); 267} 268 269sub find_selector { 270 my ( $self, $value ) = @_; 271 return $self->browser()->find_selector( $value, $self ); 272} 273 274sub find_link { 275 my ( $self, $value ) = @_; 276 return $self->browser()->find_link( $value, $self ); 277} 278 279sub find_partial { 280 my ( $self, $value ) = @_; 281 return $self->browser()->find_partial( $value, $self ); 282} 283 284sub has { 285 my ( $self, $value, $using, $from ) = @_; 286 return $self->browser()->has( $value, $using, $self ); 287} 288 289sub has_id { 290 my ( $self, $value, $from ) = @_; 291 return $self->browser()->has_id( $value, $self ); 292} 293 294sub has_name { 295 my ( $self, $value, $from ) = @_; 296 return $self->browser()->has_name( $value, $self ); 297} 298 299sub has_tag { 300 my ( $self, $value, $from ) = @_; 301 return $self->browser()->has_tag( $value, $self ); 302} 303 304sub has_class { 305 my ( $self, $value, $from ) = @_; 306 return $self->browser()->has_class( $value, $self ); 307} 308 309sub has_selector { 310 my ( $self, $value, $from ) = @_; 311 return $self->browser()->has_selector( $value, $self ); 312} 313 314sub has_link { 315 my ( $self, $value, $from ) = @_; 316 return $self->browser()->has_link( $value, $self ); 317} 318 319sub has_partial { 320 my ( $self, $value, $from ) = @_; 321 return $self->browser()->has_partial( $value, $self ); 322} 323 3241; # Magic true value required at end of module 325__END__ 326 327=head1 NAME 328 329Firefox::Marionette::Element - Represents a Firefox element retrieved using the Marionette protocol 330 331=head1 VERSION 332 333Version 1.10 334 335=head1 SYNOPSIS 336 337 use Firefox::Marionette(); 338 use v5.10; 339 340 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 341 342 my $element = $firefox->find('//input[@id="search-input"]'); 343 344 $element->type('Test::More'); 345 346=head1 DESCRIPTION 347 348This module handles the implementation of a Firefox Element using the Marionette protocol 349 350=head1 SUBROUTINES/METHODS 351 352=head2 attribute 353 354accepts a scalar name a parameter. It returns the initial value of the attribute with the supplied name. Compare with the current value returned by L<property|Firefox::Marionette::Element#property> method. 355 356=head2 browser 357 358returns the L<browser|Firefox::Marionette> connected with the L<element|Firefox::Marionette::Element>. 359 360=head2 clear 361 362clears any user supplied input from the L<element|Firefox::Marionette::Element> 363 364=head2 click 365 366sends a 'click' to the L<element|Firefox::Marionette::Element>. The browser will wait for any page load to complete or the session's L<page_load|Firefox::Marionette::Timeouts#page_load> duration to elapse before returning, which, by default is 5 minutes. The L<click|Firefox::Marionette::Element#click> method is also used to choose an option in a select dropdown. 367 368 use Firefox::Marionette(); 369 370 my $firefox = Firefox::Marionette->new(visible => 1)->go('https://ebay.com'); 371 my $select = $firefox->find_tag('select'); 372 foreach my $option ($select->find_tag('option')) { 373 if ($option->property('value') == 58058) { # Computers/Tablets & Networking 374 $option->click(); 375 } 376 } 377 378=head2 css 379 380accepts a scalar CSS property name as a parameter. It returns the value of the computed style for that property. 381 382=head2 find 383 384accepts an L<xpath expression|https://en.wikipedia.org/wiki/XPath> expression> as the first parameter and returns the first L<element|Firefox::Marionette::Element> that matches this expression. 385 386This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 387 388 use Firefox::Marionette(); 389 use v5.10; 390 391 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 392 393 my $div = $firefox->find_class('main-content'); 394 $div->find('//input[@id="search-input"]')->type('Test::More'); 395 396 # OR in list context 397 398 my $div = $firefox->find_class('main-content'); 399 foreach my $element ($div->find('//input[@id="search-input"]')) { 400 $element->type('Test::More'); 401 } 402 403If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has|Firefox::Marionette::Element#has> method. 404 405=head2 find_id 406 407accepts an L<id|https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with a matching 'id' property. 408 409This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 410 411 use Firefox::Marionette(); 412 use v5.10; 413 414 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 415 416 my $div = $firefox->find_class('main-content'); 417 $div->find_id('search-input')->type('Test::More'); 418 419 # OR in list context 420 421 my $div = $firefox->find_class('main-content'); 422 foreach my $element ($div->find_id('search-input')) { 423 $element->type('Test::More'); 424 } 425 426If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_id|Firefox::Marionette::Element#has_id> method. 427 428=head2 find_name 429 430This method returns the first L<element|Firefox::Marionette::Element> with a matching 'name' property. 431 432This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 433 434 use Firefox::Marionette(); 435 use v5.10; 436 437 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 438 439 my $div = $firefox->find_class('main-content'); 440 $div->find_name('q')->type('Test::More'); 441 442 # OR in list context 443 444 my $div = $firefox->find_class('main-content'); 445 foreach my $element ($div->find_name('q')) { 446 $element->type('Test::More'); 447 } 448 449If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_name|Firefox::Marionette::Element#has_name> method. 450 451=head2 find_class 452 453accepts a L<class name|https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with a matching 'class' property. 454 455This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 456 457 use Firefox::Marionette(); 458 use v5.10; 459 460 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 461 462 my $div = $firefox->find_class('main-content'); 463 $div->find_class('form-control home-search-input')->type('Test::More'); 464 465 # OR in list context 466 467 my $div = $firefox->find_class('main-content'); 468 foreach my $element ($div->find_class('form-control home-search-input')) { 469 $element->type('Test::More'); 470 } 471 472If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_class|Firefox::Marionette::Element#has_class> method. 473 474=head2 find_selector 475 476accepts a L<CSS Selector|https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors> as the first parameter and returns the first L<element|Firefox::Marionette::Element> that matches that selector. 477 478This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 479 480 use Firefox::Marionette(); 481 use v5.10; 482 483 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 484 485 my $div = $firefox->find_class('main-content'); 486 $div->find_selector('input.home-search-input')->type('Test::More'); 487 488 # OR in list context 489 490 my $div = $firefox->find_class('main-content'); 491 foreach my $element ($div->find_selector('input.home-search-input')) { 492 $element->type('Test::More'); 493 } 494 495If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_selector|Firefox::Marionette::Element#has_selector> method. 496 497=head2 find_tag 498 499accepts a L<tag name|https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with this tag name. 500 501This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 502 503 use Firefox::Marionette(); 504 use v5.10; 505 506 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 507 508 my $div = $firefox->find_class('main-content'); 509 my $input = $div->find_tag('input'); 510 511 # OR in list context 512 513 my $div = $firefox->find_class('main-content'); 514 foreach my $element ($div->find_tag('input')) { 515 # do something 516 } 517 518If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_tag|Firefox::Marionette::Element#has_tag> method. 519 520=head2 find_link 521 522accepts a text string as the first parameter and returns the first link L<element|Firefox::Marionette::Element> that has a matching link text. 523 524This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 525 526 use Firefox::Marionette(); 527 use v5.10; 528 529 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 530 531 my $div = $firefox->find_class('container-fluid'); 532 $div->find_link('API')->click(); 533 534 # OR in list context 535 536 my $div = $firefox->find_class('container-fluid'); 537 foreach my $element ($div->find_link('API')) { 538 $element->click(); 539 } 540 541If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_link|Firefox::Marionette::Element#has_link> method. 542 543=head2 find_partial 544 545accepts a text string as the first parameter and returns the first link L<element|Firefox::Marionette::Element> that has a partially matching link text. 546 547This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout. 548 549 use Firefox::Marionette(); 550 use v5.10; 551 552 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 553 554 my $div = $firefox->find_class('container-fluid'); 555 $div->find_partial('AP')->click(); 556 557 # OR in list context 558 559 my $div = $firefox->find_class('container-fluid'); 560 foreach my $element ($div->find_partial('AP')) { 561 $element->click(); 562 } 563 564If no elements are found, a L<not found|Firefox::Marionette::Exception::NotFound> exception will be thrown. For the same functionality that returns undef if no elements are found, see the L<has_partial|Firefox::Marionette::Element#has_partial> method. 565 566=head2 has 567 568accepts an L<xpath expression|https://en.wikipedia.org/wiki/XPath> as the first parameter and returns the first L<element|Firefox::Marionette::Element> that matches this expression. 569 570This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 571 572 use Firefox::Marionette(); 573 574 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 575 576 my $div = $firefox->find_class('main-content'); 577 if (my $element = $div->has('//input[@id="search-input"]')) { 578 $element->type('Test::More'); 579 } 580 581If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find|Firefox::Marionette::Element#find> method. 582 583=head2 has_id 584 585accepts an L<id|https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with a matching 'id' property. 586 587This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 588 589 use Firefox::Marionette(); 590 591 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 592 593 my $div = $firefox->find_class('main-content'); 594 if (my $element = $div->has_id('search-input')) { 595 $element->type('Test::More'); 596 } 597 598If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_id|Firefox::Marionette::Element#find_id> method. 599 600=head2 has_name 601 602This method returns the first L<element|Firefox::Marionette::Element> with a matching 'name' property. 603 604This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 605 606 use Firefox::Marionette(); 607 608 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 609 610 my $div = $firefox->find_class('main-content'); 611 if (my $element = $div->has_name('q')) { 612 $element->type('Test::More'); 613 } 614 615If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_name|Firefox::Marionette::Element#find_name> method. 616 617=head2 has_class 618 619accepts a L<class name|https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/class> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with a matching 'class' property. 620 621This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 622 623 use Firefox::Marionette(); 624 625 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 626 627 my $div = $firefox->find_class('main-content'); 628 if (my $element = $div->has_class('form-control home-search-input')) { 629 $element->type('Test::More'); 630 } 631 632If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_class|Firefox::Marionette::Element#find_class> method. 633 634=head2 has_selector 635 636accepts a L<CSS Selector|https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors> as the first parameter and returns the first L<element|Firefox::Marionette::Element> that matches that selector. 637 638This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 639 640 use Firefox::Marionette(); 641 642 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 643 644 my $div = $firefox->find_class('main-content'); 645 if (my $element = $div->has_selector('input.home-search-input')) { 646 $element->type('Test::More'); 647 } 648 649If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_selector|Firefox::Marionette::Element#find_selector> method. 650 651=head2 has_tag 652 653accepts a L<tag name|https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName> as the first parameter and returns the first L<element|Firefox::Marionette::Element> with this tag name. 654 655This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 656 657 use Firefox::Marionette(); 658 659 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 660 661 my $div = $firefox->find_class('main-content'); 662 if (my $element = $div->has_tag('input'); 663 # do something 664 } 665 666If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_tag|Firefox::Marionette::Element#find_tag> method. 667 668=head2 has_link 669 670accepts a text string as the first parameter and returns the first link L<element|Firefox::Marionette::Element> that has a matching link text. 671 672This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 673 674 use Firefox::Marionette(); 675 676 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 677 678 my $div = $firefox->find_class('container-fluid'); 679 if (my $element = $div->has_link('API')->click(); 680 $element->click(); 681 } 682 683If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_link|Firefox::Marionette::Element#find_link> method. 684 685=head2 has_partial 686 687accepts a text string as the first parameter and returns the first link L<element|Firefox::Marionette::Element> that has a partially matching link text. 688 689This method is subject to the L<implicit|Firefox::Marionette::Timeouts#implicit> timeout, which, by default is 0 seconds. 690 691 use Firefox::Marionette(); 692 693 my $firefox = Firefox::Marionette->new()->go('https://metacpan.org/'); 694 695 my $div = $firefox->find_class('container-fluid'); 696 if (my $element = $div->has_partial('AP')->click(); 697 $element->click(); 698 } 699 700If no elements are found, this method will return undef. For the same functionality that throws a L<not found|Firefox::Marionette::Exception::NotFound> exception, see the L<find_partial|Firefox::Marionette::Element#find_partial> method. 701 702=head2 is_enabled 703 704returns true or false if the element is enabled. 705 706=head2 is_selected 707 708returns true or false if the element is selected. 709 710=head2 is_displayed 711 712returns true or false if the element is displayed. 713 714=head2 new 715 716returns a new L<element|Firefox::Marionette::Element>. 717 718=head2 property 719 720accepts a scalar name a parameter. It returns the current value of the property with the supplied name. Compare with the initial value returned by L<attribute|Firefox::Marionette::Element#attribute> method. 721 722=head2 rect 723 724returns the current L<position and size|Firefox::Marionette::Element::Rect> of the L<element|Firefox::Marionette::Element> 725 726=head2 send_keys 727 728*** DEPRECATED - see L<type|Firefox::Marionette::Element#type>. *** 729 730=head2 selfie 731 732returns a L<File::Temp|File::Temp> object containing a lossless PNG image screenshot of the L<element|Firefox::Marionette::Element>. 733 734accepts the following optional parameters as a hash; 735 736=over 4 737 738=item * hash - return a SHA256 hex encoded digest of the PNG image rather than the image itself 739 740=item * full - take a screenshot of the whole document unless the first L<element|Firefox::Marionette::Element> parameter has been supplied. 741 742=item * scroll - scroll to the L<element|Firefox::Marionette::Element> supplied 743 744=item * highlights - a reference to a list containing L<elements|Firefox::Marionette::Element> to draw a highlight around 745 746=back 747 748=head2 switch_to_frame 749 750switches to this frame within the current window. 751 752=head2 switch_to_shadow_root 753 754switches to this element's L<shadow root|https://www.w3.org/TR/shadow-dom/> 755 756=head2 tag_name 757 758returns the relevant tag name. For example 'a' or 'input'. 759 760=head2 text 761 762returns the text that is contained by that L<element|Firefox::Marionette::Element> (if any) 763 764=head2 type 765 766accepts a scalar string as a parameter. It sends the string to this L<element|Firefox::Marionette::Element>, such as filling out a text box. This method returns L<the browser|Firefox::Marionette> to aid in chaining methods. 767 768=head2 uuid 769 770returns the browser generated UUID connected with this L<element|Firefox::Marionette::Element>. 771 772=head1 DIAGNOSTICS 773 774None. 775 776=head1 CONFIGURATION AND ENVIRONMENT 777 778Firefox::Marionette::Element requires no configuration files or environment variables. 779 780=head1 DEPENDENCIES 781 782None. 783 784=head1 INCOMPATIBILITIES 785 786None reported. 787 788=head1 BUGS AND LIMITATIONS 789 790No bugs have been reported. 791 792Please report any bugs or feature requests to 793C<bug-firefox-marionette@rt.cpan.org>, or through the web interface at 794L<http://rt.cpan.org>. 795 796=head1 AUTHOR 797 798David Dick C<< <ddick@cpan.org> >> 799 800=head1 LICENSE AND COPYRIGHT 801 802Copyright (c) 2020, David Dick C<< <ddick@cpan.org> >>. All rights reserved. 803 804This module is free software; you can redistribute it and/or 805modify it under the same terms as Perl itself. See L<perlartistic/perlartistic>. 806 807=head1 DISCLAIMER OF WARRANTY 808 809BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 810FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 811OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 812PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 813EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 814WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE 815ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH 816YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL 817NECESSARY SERVICING, REPAIR, OR CORRECTION. 818 819IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 820WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 821REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE 822LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, 823OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 824THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 825RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 826FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 827SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 828SUCH DAMAGES. 829