| 1 | package Selenium::Remote::WebElement; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 28 | $Selenium::Remote::WebElement::VERSION = '1.49'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Representation of an HTML Element used by Selenium Remote Driver | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 28 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 28 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 28 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 28 | ▶ | use Carp qw(carp croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | has 'id' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 79 | ▶ | my ($value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 79 | ▶ | if ( ref($value) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 77 | ▶ | if ( exists $value->{ELEMENT} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | # The JSONWireProtocol web element object looks like | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # { "ELEMENT": $INTEGER_ID } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 76 | return $value->{ELEMENT}; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | elsif ( exists $value->{'element-6066-11e4-a52e-4f735466cecf'} ) { | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | # but the WebDriver spec web element uses a magic | ||||||||||||||||||||||||||||||||||||||||||
| 28 | # string. See the spec for more information: | ||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # https://www.w3.org/TR/webdriver/#elements | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | return $value->{'element-6066-11e4-a52e-4f735466cecf'}; | |||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | croak | |||||||||||||||||||||||||||||||||||||||||
| 35 | 'When passing in an object to the WebElement id attribute, it must have at least one of the ELEMENT or element-6066-11e4-a52e-4f735466cecf keys.'; | ||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 28 | ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 28 | has 'driver' => ( | |||||||||||||||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | handles => [qw(_execute_command)], | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | sub child { | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | return $_[0]->{driver}->find_child_element(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
child: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | sub children { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return $_[0]->{driver}->find_child_elements(@_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | sub click { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 9 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
click: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 9 | my $res = { 'command' => 'clickElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 9 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | sub execute_script { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | my ($self, $script, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_script: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 70 | $script, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} }, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | @args ); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | sub execute_async_script { | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | my ($self, $script, @args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_async_script: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | return $self->driver->execute_async_script( | ||||||||||||||||||||||||||||||||||||||||||
| 78 | $script, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} }, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | @args ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | sub submit { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
submit: called CC=4 SCAR=20.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 89 | && !( | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | grep { $self->driver->browser_name eq $_ } qw{MicrosoftEdge} | |||||||||||||||||||||||||||||||||||||||||
| 91 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( $self->get_tag_name() ne 'form' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 96 | "return arguments[0].form.submit();", | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} } ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 101 | "return arguments[0].submit();", | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} } ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | my $res = { 'command' => 'submitElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | sub send_keys { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | my ( $self, @strings ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_keys: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | croak "no keys to send" unless scalar @strings >= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 3 | my $res = { 'command' => 'sendKeysToElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | # We need to send an array of single characters to be WebDriver | ||||||||||||||||||||||||||||||||||||||||||
| 116 | # spec compatible. That is, for @strings = ('hel', 'lo'), the | ||||||||||||||||||||||||||||||||||||||||||
| 117 | # corresponding value must be ('h', 'e', 'l', 'l', 'o' ). This | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # format conforms with the Spec AND works with the Selenium | ||||||||||||||||||||||||||||||||||||||||||
| 119 | # standalone server. | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | my $strings = join( '', map { $_ . "" } @strings ); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 3 | my $params = { | |||||||||||||||||||||||||||||||||||||||||
| 122 | 'value' => [ split( '', $strings ) ], | ||||||||||||||||||||||||||||||||||||||||||
| 123 | text => $strings, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | sub is_selected { | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_selected: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | my $to_check = $self->get_tag_name() eq 'option' ? 'selected' : 'checked'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | return $self->get_property($to_check) | ||||||||||||||||||||||||||||||||||||||||||
| 134 | if $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | ▶ | && !( grep { $self->driver->browser_name eq $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | qw{chrome MicrosoftEdge} ); | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | my $res = { 'command' => 'isElementSelected', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | sub set_selected { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_selected: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( $self->driver->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return if $self->is_selected(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | return $self->click(); | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $res = { 'command' => 'setElementSelected', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | sub toggle { | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toggle: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | if ( $self->driver->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | return $self->click() unless $self->is_selected(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 158 | qq/ if (arguments[0].checked) { arguments[0].checked = 0 }; return arguments[0].checked; /, | ||||||||||||||||||||||||||||||||||||||||||
| 159 | { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my $res = { 'command' => 'toggleElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | sub is_enabled { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_enabled: called CC=5 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 171 | && !( | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge} | |||||||||||||||||||||||||||||||||||||||||
| 173 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 174 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | return 1 if $self->get_tag_name() ne 'input'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | return $self->get_property('disabled') ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | my $res = { 'command' => 'isElementEnabled', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | sub get_element_location { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_element_location: called CC=3 SCAR=15.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 188 | && !( | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge} | |||||||||||||||||||||||||||||||||||||||||
| 190 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 191 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $data = $self->get_element_rect(); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | delete $data->{height}; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | delete $data->{width}; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | my $res = { 'command' => 'getElementLocation', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | sub get_size { | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_size: called CC=3 SCAR=15.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 207 | && !( | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge} | |||||||||||||||||||||||||||||||||||||||||
| 209 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 210 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $data = $self->get_element_rect(); | |||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | delete $data->{x}; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | delete $data->{y}; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 1 | my $res = { 'command' => 'getElementSize', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | sub get_element_rect { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_element_rect: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my $res = { 'command' => 'getElementRect', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | sub get_element_location_in_view { | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_element_location_in_view: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | #XXX chrome is dopey here | ||||||||||||||||||||||||||||||||||||||||||
| 233 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 234 | qq{ | ||||||||||||||||||||||||||||||||||||||||||
| 235 | if (typeof(arguments[0]) !== 'undefined' && arguments[0].nodeType === Node.ELEMENT_NODE) { | ||||||||||||||||||||||||||||||||||||||||||
| 236 | arguments[0].scrollIntoView(); | ||||||||||||||||||||||||||||||||||||||||||
| 237 | var pos = arguments[0].getBoundingClientRect(); | ||||||||||||||||||||||||||||||||||||||||||
| 238 | return {y:pos.top,x:pos.left}; | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | return {}; | ||||||||||||||||||||||||||||||||||||||||||
| 241 | }, { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if $self->driver->{is_wd3} && grep { $self->driver->browser_name eq $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->driver->{"is_wd3"} and grep {$self->driver->browser_name eq $_;} "firefox", "internet explorer", "chrome"
MC/DC0%0/2
$self->driver->{"is_wd3"} and grep {$self->driver->browser_name eq $_;} "firefox", "internet explorer", "chrome"
$self->driver->{"is_wd3"}
grep {$self->driver->browser_name eq $_;} "firefox", "internet explorer", "chrome"
Truth table0%0/3
A and B
A= $self->driver->{"is_wd3"}B= grep {$self->driver->browser_name eq $_;} "firefox", "internet explorer", "chrome"
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | ( 'firefox', 'internet explorer', 'chrome' ); | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $res = { 'command' => 'getElementLocationInView', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | sub get_tag_name { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_tag_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 5 | my $res = { 'command' => 'getElementTagName', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 5 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | sub clear { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | my $res = { 'command' => 'clearElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | sub get_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 17 | ▶ | my ( $self, $attr_name, $no_i_really_mean_it ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_attribute: called CC=6 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 17 | ▶ | if ( not defined $attr_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | croak 'Attribute name not provided'; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | #Handle global JSONWire emulation flag | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 17 | ▶ | $no_i_really_mean_it = 1 unless $self->{driver}->{emulate_jsonwire}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | return $self->get_property($attr_name) | ||||||||||||||||||||||||||||||||||||||||||
| 274 | if $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 17 | ▶ | && !( grep { $self->driver->browser_name eq $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge") and not $no_i_really_mean_it
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge") and not $no_i_really_mean_it
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
not $no_i_really_mean_it
Truth table25%1/4
A and not(B) and not(C)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")C= not $no_i_really_mean_it
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | qw{chrome MicrosoftEdge} ) | ||||||||||||||||||||||||||||||||||||||||||
| 277 | && !$no_i_really_mean_it; | ||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||
| 279 | 17 | my $res = { | |||||||||||||||||||||||||||||||||||||||||
| 280 | 'command' => 'getElementAttribute', | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 'id' => $self->id, | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 'name' => $attr_name, | ||||||||||||||||||||||||||||||||||||||||||
| 283 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 17 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | sub get_property { | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my ( $self, $prop ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_property: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | return $self->get_attribute($prop) | ||||||||||||||||||||||||||||||||||||||||||
| 291 | if $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | && ( grep { $self->driver->browser_name eq $_ } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->driver->{"is_wd3"} and grep {$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge"
MC/DC0%0/2
$self->driver->{"is_wd3"} and grep {$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge"
$self->driver->{"is_wd3"}
grep {$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge"
Truth table0%0/3
A and B
A= $self->driver->{"is_wd3"}B= grep {$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge"
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | qw{chrome MicrosoftEdge} ); | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $res = | |||||||||||||||||||||||||||||||||||||||||
| 295 | { 'command' => 'getElementProperty', id => $self->id, name => $prop }; | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | sub get_value { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 9 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_value: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 9 | return $self->get_attribute('value'); | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | sub is_displayed { | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_displayed: called CC=6 SCAR=29.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 6 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
MC/DC0%0/2
$self->driver->{"is_wd3"} and not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
$self->driver->{"is_wd3"}
not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->driver->{"is_wd3"}B= not grep({$self->driver->browser_name eq $_;} "chrome", "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | $self->driver->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 310 | && !( | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | grep { $self->driver->browser_name eq $_ } qw{chrome MicrosoftEdge} | |||||||||||||||||||||||||||||||||||||||||
| 312 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 313 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | return 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_tag_name eq "input" and $self->get_property("type") eq "hidden"
MC/DC0%0/2
$self->get_tag_name eq "input" and $self->get_property("type") eq "hidden"
$self->get_tag_name eq "input"
$self->get_property("type") eq "hidden"
Truth table0%0/3
A and B
A= $self->get_tag_name eq "input"B= $self->get_property("type") eq "hidden"
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | if $self->get_tag_name() eq 'input' | ||||||||||||||||||||||||||||||||||||||||||
| 317 | && $self->get_property('type') eq 'hidden'; #hidden type inputs | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return 0 unless $self->_is_in_viewport(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | return int( $self->get_css_attribute('display') ne 'none' ); | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 6 | my $res = { 'command' => 'isElementDisplayed', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 6 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | sub _is_in_viewport { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_in_viewport: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | return $self->driver->execute_script( | ||||||||||||||||||||||||||||||||||||||||||
| 328 | qq{ | ||||||||||||||||||||||||||||||||||||||||||
| 329 | var rect = arguments[0].getBoundingClientRect(); | ||||||||||||||||||||||||||||||||||||||||||
| 330 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 331 | rect.top >= 0 && | ||||||||||||||||||||||||||||||||||||||||||
| 332 | rect.left >= 0 && | ||||||||||||||||||||||||||||||||||||||||||
| 333 | rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && | ||||||||||||||||||||||||||||||||||||||||||
| 334 | rect.right <= (window.innerWidth || document.documentElement.clientWidth) | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | }, { 'element-6066-11e4-a52e-4f735466cecf' => $self->{id} } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | sub is_hidden { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hidden: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 2 | return !$self->is_displayed(); | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | sub drag { | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | my ( $self, $target ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drag: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | require Selenium::ActionChains; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my $chain = Selenium::ActionChains->new( driver => $self->driver ); | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return $chain->drag_and_drop( $self, $target )->perform(); | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | sub get_text { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 21 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 21 | my $res = { 'command' => 'getElementText', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 358 | 21 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | sub get_css_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | my ( $self, $attr_name ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_css_attribute: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ( not defined $attr_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | croak 'CSS attribute name not provided'; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $res = { | |||||||||||||||||||||||||||||||||||||||||
| 368 | 'command' => 'getElementValueOfCssProperty', | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 'id' => $self->id, | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 'property_name' => $attr_name, | ||||||||||||||||||||||||||||||||||||||||||
| 371 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | sub describe { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
describe: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $res = { 'command' => 'describeElement', 'id' => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | sub screenshot { | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my ( $self, $scroll ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
screenshot: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | $scroll //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$scroll //= 1
MC/DC0%0/1
$scroll //= 1
$scroll
Truth table0%0/2
A
A= $scroll
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $res = { 'command' => 'elementScreenshot', id => $self->id }; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $input = { scroll => int($scroll) }; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | return $self->_execute_command( $res, $input ); | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | sub capture_screenshot { | ||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | my ( $self, $filename, $scroll ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture_screenshot: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | croak '$filename is required' unless $filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | open( my $fh, '>', $filename ); | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | print $fh MIME::Base64::decode_base64( $self->screenshot($scroll) ); | |||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | CORE::close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 28 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | Selenium::Remote::WebElement - Representation of an HTML Element used by Selenium Remote Driver | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | version 1.49 | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | Selenium Webdriver represents all the HTML elements as WebElements. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | This module provides a mechanism to represent them as objects & | ||||||||||||||||||||||||||||||||||||||||||
| 423 | perform various actions on the related elements. This module should | ||||||||||||||||||||||||||||||||||||||||||
| 424 | not be instantiated directly by the end user. Selenium::Remote::Driver | ||||||||||||||||||||||||||||||||||||||||||
| 425 | instantiates this module when required. Typically, the find_element | ||||||||||||||||||||||||||||||||||||||||||
| 426 | method in Selenium::Remote::Driver returns this object on which | ||||||||||||||||||||||||||||||||||||||||||
| 427 | various element related operations can be carried out. | ||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | What is probably most useful on this page is the list of methods below | ||||||||||||||||||||||||||||||||||||||||||
| 430 | that you can perform on an element once you've found one and S::R::D | ||||||||||||||||||||||||||||||||||||||||||
| 431 | has made an instance of this for you. | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | =item B<id> | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | Required: Pass in a string representing the ID of the object. The | ||||||||||||||||||||||||||||||||||||||||||
| 442 | string should be obtained from the response object of making one of | ||||||||||||||||||||||||||||||||||||||||||
| 443 | the C<find_element> calls from L<Selenium::Remote::Driver>. | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | The attribute is also set up to handle spec compliant element response | ||||||||||||||||||||||||||||||||||||||||||
| 446 | objects via its `coerce` such that any of the following will work and | ||||||||||||||||||||||||||||||||||||||||||
| 447 | are all equivalent: | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | my $old_elem = Selenium::Remote::WebElement->new( | ||||||||||||||||||||||||||||||||||||||||||
| 450 | id => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 451 | driver => $driver | ||||||||||||||||||||||||||||||||||||||||||
| 452 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | my $new_remote_elem = Selenium::Remote::WebElement->new( | ||||||||||||||||||||||||||||||||||||||||||
| 455 | id => { ELEMENT => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 456 | driver => $driver | ||||||||||||||||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | my $new_spec_elem = Selenium::Remote::WebElement->new( | ||||||||||||||||||||||||||||||||||||||||||
| 460 | id => { 'element-6066-11e4-a52e-4f735466cecf' => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 461 | driver => $driver | ||||||||||||||||||||||||||||||||||||||||||
| 462 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | and then after instantiation, all three would give the following for | ||||||||||||||||||||||||||||||||||||||||||
| 465 | `id`: | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | print $elem->id; # prints 1 | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | =item B<driver> | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | Required: Pass in a Selenium::Remote::Driver instance or one of its | ||||||||||||||||||||||||||||||||||||||||||
| 472 | subclasses. The WebElement needs the appropriate Driver session to | ||||||||||||||||||||||||||||||||||||||||||
| 473 | execute its commands properly. | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | For typical usage of S::R::D and this module, none of this | ||||||||||||||||||||||||||||||||||||||||||
| 478 | matters and it should Just Work without you having to worry about it | ||||||||||||||||||||||||||||||||||||||||||
| 479 | at all. For further reading, the L<W3C | ||||||||||||||||||||||||||||||||||||||||||
| 480 | spec|https://www.w3.org/TR/webdriver/#elements> strictly dictates the | ||||||||||||||||||||||||||||||||||||||||||
| 481 | exact behavior. | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | =head2 child(selector, method) | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | =head2 children(selector, method) | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | Alias to Selenium::Remote::Driver::find_child_element and find_child_elements, respectively. | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | =head2 click | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 494 | Click the element. | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 497 | $elem->click(); | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =head2 execute_script($script, @args), execute_async_script($script, @args) | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | Convenience method to execute a script with the element passed as the first argument to the script function, and the remaining args appended. | ||||||||||||||||||||||||||||||||||||||||||
| 502 | See the documentation for Selenium::Remote::Driver::execute_script for more information. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | =head2 submit | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 507 | Submit a FORM element. The submit command may also be applied to any element | ||||||||||||||||||||||||||||||||||||||||||
| 508 | that is a descendant of a FORM element. | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 511 | On webdriver3 enabled servers, this uses a JS shim, which WILL NOT submit correctly unless your element is an <input>. | ||||||||||||||||||||||||||||||||||||||||||
| 512 | Try clicking it if possible instead. | ||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||
| 514 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 515 | $elem->submit(); | ||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | =head2 send_keys | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 520 | Send a sequence of key strokes to an element. If you want to send specific | ||||||||||||||||||||||||||||||||||||||||||
| 521 | Keyboard events, then use the WDKeys module along with theis method. See e.g. | ||||||||||||||||||||||||||||||||||||||||||
| 522 | for reference | ||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||
| 524 | Input: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 525 | Required: | ||||||||||||||||||||||||||||||||||||||||||
| 526 | {ARRAY | STRING} - Array of strings or a string. | ||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 529 | $elem->send_keys('abcd', 'efg'); | ||||||||||||||||||||||||||||||||||||||||||
| 530 | $elem->send_keys('hijk'); | ||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | or | ||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | # include the WDKeys module | ||||||||||||||||||||||||||||||||||||||||||
| 535 | use Selenium::Remote::WDKeys; | ||||||||||||||||||||||||||||||||||||||||||
| 536 | . | ||||||||||||||||||||||||||||||||||||||||||
| 537 | . | ||||||||||||||||||||||||||||||||||||||||||
| 538 | $elem->send_keys(KEYS->{'space'}, KEYS->{'enter'}); | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | =head2 is_selected | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 543 | Determine if an OPTION element, or an INPUT element of type checkbox or | ||||||||||||||||||||||||||||||||||||||||||
| 544 | radiobutton is currently selected. | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 547 | BOOLEAN - whether the element is selected | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 550 | $elem->is_selected(); | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | =head2 set_selected | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 555 | Select an OPTION element, or an INPUT element of type checkbox or radiobutton. | ||||||||||||||||||||||||||||||||||||||||||
| 556 | Forces selected=1 on the element.. | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 559 | $elem->set_selected(); | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head2 toggle | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 564 | Toggle whether an OPTION element, or an INPUT element of type checkbox or | ||||||||||||||||||||||||||||||||||||||||||
| 565 | radiobutton is currently selected. | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 568 | BOOLEAN - Whether the element is selected after toggling its state. | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 571 | $elem->toggle(); | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | =head2 is_enabled | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 576 | Determine if an element is currently enabled. | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 579 | BOOLEAN - Whether the element is enabled. | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 582 | $elem->is_enabled(); | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | =head2 get_element_location | ||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 587 | Determine an element's location on the page. The point (0, 0) refers to the | ||||||||||||||||||||||||||||||||||||||||||
| 588 | upper-left corner of the page. | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 591 | On WebDriver 3 enabled servers, this is an alias for get_element_rect(). | ||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 594 | HASH - The X and Y coordinates for the element on the page. | ||||||||||||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||||||||||||
| 596 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 597 | $elem->get_element_location(); | ||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||
| 599 | This method is DEPRECATED on webdriver3 enabled servers. | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | =head2 get_size | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 604 | Determine an element's size in pixels. The size will be returned with width | ||||||||||||||||||||||||||||||||||||||||||
| 605 | and height properties. | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 608 | On WebDriver 3 enabled servers, this is an alias for get_element_rect(). | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 611 | HASH - The width and height of the element, in pixels. | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 614 | $elem->get_size(); | ||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | This method is DEPRECATED on webdriver3 enabled servers. | ||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | =head2 get_element_rect | ||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | Get the element's size AND location in a hash. | ||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||
| 622 | Example Output: | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | { x => 0, y => 0, height => 10, width => 10 } | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | =head2 get_element_location_in_view | ||||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 629 | Determine an element's location on the screen once it has been scrolled | ||||||||||||||||||||||||||||||||||||||||||
| 630 | into view. | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | Note: This is considered an internal command and should only be used to | ||||||||||||||||||||||||||||||||||||||||||
| 633 | determine an element's location for correctly generating native events. | ||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 636 | On Webdriver3 servers, we have to implement this with a JS shim. | ||||||||||||||||||||||||||||||||||||||||||
| 637 | This means in some contexts, you won't get any position returned, as the element isn't considered an element internally. | ||||||||||||||||||||||||||||||||||||||||||
| 638 | You may have to go up the element stack to find the element that actually has the bounding box. | ||||||||||||||||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||||||||||||||||
| 640 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 641 | {x:number, y:number} The X and Y coordinates for the element on the page. | ||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 644 | $elem->get_element_location_in_view(); | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | =head2 get_tag_name | ||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 649 | Query for an element's tag name. | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 652 | STRING - The element's tag name, as a lowercase string. | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 655 | $elem->get_tag_name(); | ||||||||||||||||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||||||||||||||||
| 657 | =head2 clear | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 660 | Clear a TEXTAREA or text INPUT element's value. | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 663 | $elem->clear(); | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | =head2 get_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 668 | Get the value of an element's attribute. | ||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 671 | In older webDriver, this actually got the value of an element's property. | ||||||||||||||||||||||||||||||||||||||||||
| 672 | If you want to get the initial condition (e.g. the values in the tag hardcoded in HTML), pass 1 as the second argument. | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | Or, set $driver->{emulate_jsonwire} = 0 to not have to pass the extra arg. | ||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||
| 676 | This can only done on WebDriver 3 enabled servers. | ||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||
| 678 | Input: 2 | ||||||||||||||||||||||||||||||||||||||||||
| 679 | Required: | ||||||||||||||||||||||||||||||||||||||||||
| 680 | STRING - name of the attribute of the element | ||||||||||||||||||||||||||||||||||||||||||
| 681 | Optional: | ||||||||||||||||||||||||||||||||||||||||||
| 682 | BOOLEAN - "I really mean that I want the initial condition, quit being so compatible!!!" | ||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 686 | {STRING | NULL} The value of the attribute, or null if it is not set on the element. | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 689 | $elem->get_attribute('name',1); | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | =head2 get_property | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | Gets the C<Current Value> of an element's attribute. | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | Takes a named property as an argument. | ||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | Only available on WebDriver 3 enabled servers. | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | =head2 get_value | ||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 702 | Query for the value of an element, as determined by its value attribute. | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 705 | {STRING | NULL} The element's value, or null if it doesn't have a value attribute. | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 708 | $elem->get_value(); | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | =head2 is_displayed | ||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 713 | Determine if an element is currently displayed. | ||||||||||||||||||||||||||||||||||||||||||
| 714 | Note: This does *not* tell you an element's 'visibility' property; as it still takes up space in the DOM and is therefore considered 'displayed'. | ||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||
| 716 | WC3 Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 717 | On JSONWire this method really only checked to see whether the element's style was display:none, or whether it was a hidden input. | ||||||||||||||||||||||||||||||||||||||||||
| 718 | This is because "displayedness" was pretty loosely defined until fairly late on into the process, and much grief resulted. | ||||||||||||||||||||||||||||||||||||||||||
| 719 | In WC3 webdriver, it additionally does a viewport check, to account for the firmer definition of "displayedness": | ||||||||||||||||||||||||||||||||||||||||||
| 720 | https://w3c.github.io/webdriver/#element-displayedness | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 723 | BOOLEAN - Whether the element is displayed. | ||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||
| 725 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 726 | $elem->is_displayed(); | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | =head2 is_hidden | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 731 | Determine if an element is currently hidden. | ||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||
| 733 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 734 | BOOLEAN - Whether the element is hidden. | ||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||
| 736 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 737 | $elem->is_hidden(); | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | =head2 drag | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | Alias for Selenium::ActionChains::drag_and_drop(). | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | Provide element you wish to drag to as argument. | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | my $target = $driver->find_element('receptacle','id'); | ||||||||||||||||||||||||||||||||||||||||||
| 746 | my $subject = $driver->find_element('thingy','id'); | ||||||||||||||||||||||||||||||||||||||||||
| 747 | $subject->drag($target); | ||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||
| 749 | =head2 get_text | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 752 | Get the innerText of the element. | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 755 | STRING - innerText of an element | ||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||
| 757 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 758 | $elem->get_text(); | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | =head2 get_css_attribute | ||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 763 | Query the value of an element's computed CSS property. The CSS property to | ||||||||||||||||||||||||||||||||||||||||||
| 764 | query should be specified using the CSS property name, not the JavaScript | ||||||||||||||||||||||||||||||||||||||||||
| 765 | property name (e.g. background-color instead of backgroundColor). | ||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | Input: 1 | ||||||||||||||||||||||||||||||||||||||||||
| 768 | Required: | ||||||||||||||||||||||||||||||||||||||||||
| 769 | STRING - name of the css-attribute | ||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 772 | STRING - Value of the css attribute | ||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 775 | $elem->get_css_attribute('background-color'); | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | =head2 describe | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 780 | Describe the identified element | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 783 | $elem->describe(); | ||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||
| 785 | Note: DEPRECATED as of 2.42.2 -- use get_text, get_value, is_displayed, or | ||||||||||||||||||||||||||||||||||||||||||
| 786 | whatever appropriate WebElement function you need instead | ||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||
| 788 | Entirely unsupported on WebDriver 3 enabled servers. | ||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | =head2 screenshot | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 793 | Get a screenshot of the visible region that is a subset of the element's bounding box as a base64 encoded image. | ||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||
| 795 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 796 | Only available on Webdriver3 enabled selenium servers. | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | Input (optional): | ||||||||||||||||||||||||||||||||||||||||||
| 799 | $scroll_into_view - BOOLEAN default true. If false, will not scroll the element into the viewport first. | ||||||||||||||||||||||||||||||||||||||||||
| 800 | Failing to do so may result in an image being cropped partially or entirely. | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 803 | STRING - base64 encoded image | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 806 | print $element->screenshot(); | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | To conveniently write the screenshot to a file, see L</capture_screenshot>. | ||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||
| 810 | =head2 capture_screenshot | ||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | Description: | ||||||||||||||||||||||||||||||||||||||||||
| 813 | Capture a screenshot of said element and save as a PNG to provided file name. | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | Compatibility: | ||||||||||||||||||||||||||||||||||||||||||
| 816 | Only available on Webdriver3 enabled selenium servers. | ||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||
| 818 | Input (optional): | ||||||||||||||||||||||||||||||||||||||||||
| 819 | $scroll_into_view - BOOLEAN default true. If false, will not scroll the element into the viewport first. | ||||||||||||||||||||||||||||||||||||||||||
| 820 | Failing to do so may result in an image being cropped partially or entirely. | ||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||
| 822 | Output: | ||||||||||||||||||||||||||||||||||||||||||
| 823 | TRUE - (Screenshot is written to file) | ||||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | Usage: | ||||||||||||||||||||||||||||||||||||||||||
| 826 | $element->capture_screenshot($filename); | ||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||
| 828 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | Current Maintainers: | ||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||
| 832 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||
| 836 | George S. Baugh <george@troglodyne.net> | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | Previous maintainers: | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||
| 846 | Daniel Gempesaw <gempesaw@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | Emmanuel Peroumalnaïk <peroumalnaik.emmanuel@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | Luke Closs <cpan@5thplane.com> | ||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||
| 858 | Mark Stosberg <mark@stosberg.com> | ||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||
| 860 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | Original authors: | ||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||
| 864 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | Aditya Ivaturi <ivaturi@gmail.com> | ||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||
| 870 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | Copyright (c) 2010-2011 Aditya Ivaturi, Gordon Child | ||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | Copyright (c) 2014-2017 Daniel Gempesaw | ||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||
| 878 | Copyright (c) 2018-2021 George S. Baugh | ||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||
| 880 | Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||||||||||||||||||||||||||||||||||
| 881 | you may not use this file except in compliance with the License. | ||||||||||||||||||||||||||||||||||||||||||
| 882 | You may obtain a copy of the License at | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||
| 886 | Unless required by applicable law or agreed to in writing, software | ||||||||||||||||||||||||||||||||||||||||||
| 887 | distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||||||||||||||||||||||||||||||||||
| 888 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||||||||||||||||||||||||||||||||||
| 889 | See the License for the specific language governing permissions and | ||||||||||||||||||||||||||||||||||||||||||
| 890 | limitations under the License. | ||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | =cut | ||||||||||||||||||||||||||||||||||||||||||