| 1 | package Selenium::Remote::Driver; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 26 | $Selenium::Remote::Driver::VERSION = '1.50'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | 26 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 26 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Perl Client for Selenium Remote Driver | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 26 | ▶ | use Moo; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 26 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 26 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 26 | ▶ | use v5.10.0; # Before 5.006, v5.10.0 would not be understood. | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | # See http://perldoc.perl.org/5.10.0/functions/use.html#use-VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # and http://www.dagolden.com/index.php/369/version-numbers-should-be-boring/ | ||||||||||||||||||||||||||||||||||||||||||
| 16 | # for details. | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 26 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 26 | our @CARP_NOT; | |||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 26 | ▶ | use IO::String; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 26 | ▶ | use Archive::Zip qw( :ERROR_CODES ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 26 | ▶ | use Scalar::Util; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 26 | ▶ | use Selenium::Remote::RemoteConnection; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | 26 | ▶ | use Selenium::Remote::Commands; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 26 | ▶ | use Selenium::Remote::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 26 | ▶ | use Selenium::Remote::WebElement; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 26 | ▶ | use Selenium::Remote::WDKeys; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 26 | ▶ | use File::Spec::Functions (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 26 | ▶ | use File::Basename qw(basename); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 26 | ▶ | use Sub::Install (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 26 | ▶ | use MIME::Base64 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 26 | ▶ | use Time::HiRes qw(usleep); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 26 | ▶ | use Clone qw{clone}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 26 | ▶ | use List::Util qw{any}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 26 | ▶ | use constant FINDERS => { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | class => 'class name', | ||||||||||||||||||||||||||||||||||||||||||
| 39 | class_name => 'class name', | ||||||||||||||||||||||||||||||||||||||||||
| 40 | css => 'css selector', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | id => 'id', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | link => 'link text', | ||||||||||||||||||||||||||||||||||||||||||
| 43 | link_text => 'link text', | ||||||||||||||||||||||||||||||||||||||||||
| 44 | name => 'name', | ||||||||||||||||||||||||||||||||||||||||||
| 45 | partial_link_text => 'partial link text', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | tag_name => 'tag name', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | xpath => 'xpath', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 26 | our $FORCE_WD2 = 0; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 26 | our $FORCE_WD3 = 0; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 26 | our %CURRENT_ACTION_CHAIN = ( actions => [] ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | has 'remote_server_addr' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 58 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 32 | ▶ | coerce => sub { ( defined( $_[0] ) ? $_[0] : 'localhost' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 28 | ▶ | default => sub { 'localhost' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 26 | predicate => 1 | |||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | has 'browser_name' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 35 | ▶ | coerce => sub { ( defined( $_[0] ) ? $_[0] : 'firefox' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 11 | ▶ | default => sub { 'firefox' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | has 'base_url' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 71 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | ▶ | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 6 | my $base_url = shift; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 6 | $base_url =~ s|/$||; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 6 | return $base_url; | |||||||||||||||||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 26 | predicate => 'has_base_url', | |||||||||||||||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | has 'platform' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 81 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 34 | ▶ | coerce => sub { ( defined( $_[0] ) ? $_[0] : 'ANY' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 32 | ▶ | default => sub { 'ANY' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | has 'port' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 87 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 30 | ▶ | coerce => sub { ( defined( $_[0] ) ? $_[0] : '4444' ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 29 | ▶ | default => sub { '4444' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 26 | predicate => 1 | |||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | has 'version' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 94 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 32 | ▶ | default => sub { '' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | has 'webelement_class' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 99 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 23 | ▶ | default => sub { 'Selenium::Remote::WebElement' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | has 'default_finder' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 104 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 40 | ▶ | coerce => sub { __PACKAGE__->FINDERS->{ $_[0] } }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | 31 | ▶ | default => sub { 'xpath' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | has 'session_id' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 110 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 31 | ▶ | default => sub { undef }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | has 'remote_conn' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 115 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 9 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_remote_conn: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 9 | return Selenium::Remote::RemoteConnection->new( | |||||||||||||||||||||||||||||||||||||||||
| 119 | remote_server_addr => $self->remote_server_addr, | ||||||||||||||||||||||||||||||||||||||||||
| 120 | port => $self->port, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ua => $self->ua, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | wd_context_prefix => $self->wd_context_prefix | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 124 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | has 'error_handler' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 128 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | ▶ | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | my ($maybe_coderef) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | ▶ | if ( ref($maybe_coderef) eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 3 | return $maybe_coderef; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | croak 'The error handler must be a code ref.'; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 26 | clearer => 1, | |||||||||||||||||||||||||||||||||||||||||
| 140 | predicate => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 141 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | has 'ua' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 144 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | builder => sub { return LWP::UserAgent->new } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | has 'commands' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 149 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 24 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 24 | return Selenium::Remote::Commands->new; | |||||||||||||||||||||||||||||||||||||||||
| 152 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | has 'commands_v3' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 156 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 29 | ▶ | builder => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_commands_v3: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 29 | return Selenium::Remote::Spec->new; | |||||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 160 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | has 'auto_close' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 163 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 38 | ▶ | coerce => sub { ( defined( $_[0] ) ? $_[0] : 1 ) }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 31 | ▶ | default => sub { 1 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | has 'pid' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 169 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 170 | 35 | ▶ | builder => sub { return $$ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | has 'javascript' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 174 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 34 | ▶ | coerce => sub { $_[0] ? JSON::true : JSON::false }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 30 | ▶ | default => sub { return JSON::true } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | has 'accept_ssl_certs' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 180 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 35 | ▶ | coerce => sub { $_[0] ? JSON::true : JSON::false }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 35 | ▶ | default => sub { return JSON::true } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | has 'proxy' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 186 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | ▶ | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | my $proxy = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | ▶ | if ( $proxy->{proxyType} =~ /^pac$/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | ▶ | if ( not defined $proxy->{proxyAutoconfigUrl} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | croak "proxyAutoconfigUrl not provided\n"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | elsif ( not( $proxy->{proxyAutoconfigUrl} =~ /^(http|file)/g ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | croak | |||||||||||||||||||||||||||||||||||||||||
| 195 | "proxyAutoconfigUrl should be of format http:// or file://"; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | if ( $proxy->{proxyAutoconfigUrl} =~ /^file/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | my $pac_url = $proxy->{proxyAutoconfigUrl}; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | my $file = $pac_url; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | $file =~ s{^file://}{}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | ▶ | if ( !-e $file ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | warn "proxyAutoConfigUrl file does not exist: '$pac_url'"; | |||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | $proxy; | |||||||||||||||||||||||||||||||||||||||||
| 209 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | has 'extra_capabilities' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 213 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 34 | ▶ | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | has 'firefox_profile' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 218 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | ▶ | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.3
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | my $profile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | ▶ | unless ( Scalar::Util::blessed($profile) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($profile) and $profile->isa("Selenium::Firefox::Profile")
MC/DC0%0/2
builtin::blessed($profile) and $profile->isa("Selenium::Firefox::Profile")
builtin::blessed($profile)
$profile->isa("Selenium::Firefox::Profile")
Truth table33%1/3
A and B
A= builtin::blessed($profile)B= $profile->isa("Selenium::Firefox::Profile")
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | && $profile->isa('Selenium::Firefox::Profile') ) | ||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | croak "firefox_profile should be a Selenium::Firefox::Profile\n"; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return $profile; | |||||||||||||||||||||||||||||||||||||||||
| 228 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 26 | predicate => 'has_firefox_profile', | |||||||||||||||||||||||||||||||||||||||||
| 230 | clearer => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | has debug => ( | ||||||||||||||||||||||||||||||||||||||||||
| 234 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 30 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 26 | has 'desired_capabilities' => ( | |||||||||||||||||||||||||||||||||||||||||
| 239 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 240 | predicate => 'has_desired_capabilities' | ||||||||||||||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | has 'inner_window_size' => ( | ||||||||||||||||||||||||||||||||||||||||||
| 244 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 245 | predicate => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | coerce => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $size = shift; | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | croak "inner_window_size must have two elements: [ height, width ]" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 250 | unless scalar @$size == 2; | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | foreach my $dim (@$size) { | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | croak 'inner_window_size only accepts integers, not: ' . $dim | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | unless Scalar::Util::looks_like_number($dim); | ||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return $size; | |||||||||||||||||||||||||||||||||||||||||
| 258 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 26 | ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # At the time of writing, Geckodriver uses a different endpoint than | ||||||||||||||||||||||||||||||||||||||||||
| 263 | # the java bindings for executing synchronous and asynchronous | ||||||||||||||||||||||||||||||||||||||||||
| 264 | # scripts. As a matter of fact, Geckodriver does conform to the W3C | ||||||||||||||||||||||||||||||||||||||||||
| 265 | # spec, but as are bound to support both while the java bindings | ||||||||||||||||||||||||||||||||||||||||||
| 266 | # transition to full spec support, we need some way to handle the | ||||||||||||||||||||||||||||||||||||||||||
| 267 | # difference. | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 26 | has '_execute_script_suffix' => ( | |||||||||||||||||||||||||||||||||||||||||
| 270 | is => 'lazy', | ||||||||||||||||||||||||||||||||||||||||||
| 271 | default => '' | ||||||||||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | 26 | with 'Selenium::Remote::Finders'; | |||||||||||||||||||||||||||||||||||||||||
| 275 | 26 | with 'Selenium::Remote::Driver::CanSetWebdriverContext'; | |||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 32 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=8 SCAR=21.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 32 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 32 | ▶ | if ( !( defined $self->session_id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 31 | ▶ | if ( $self->has_desired_capabilities ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 5 | $self->new_desired_session( $self->desired_capabilities ); | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | # Connect to remote server & establish a new session | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 26 | $self->new_session( $self->extra_capabilities ); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 30 | ▶ | if ( !( defined $self->session_id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | croak "Could not establish a session with the remote server\n"; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | elsif ( $self->has_inner_window_size ) { | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $size = $self->inner_window_size; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $self->set_inner_window_size(@$size); | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | #Set debug if needed | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 30 | ▶ | $self->debug_on() if $self->debug; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | # Setup non-croaking, parameter versions of finders | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 30 | foreach my $by ( keys %{ $self->FINDERS } ) { | |||||||||||||||||||||||||||||||||||||||||
| 303 | 300 | my $finder_name = 'find_element_by_' . $by; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # In case we get instantiated multiple times, we don't want to | ||||||||||||||||||||||||||||||||||||||||||
| 306 | # install into the name space every time. | ||||||||||||||||||||||||||||||||||||||||||
| 307 | 300 | ▶ | unless ( $self->can($finder_name) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 110 | my $find_sub = $self->_build_find_by($by); | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 110 | Sub::Install::install_sub( | |||||||||||||||||||||||||||||||||||||||||
| 311 | { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | code => $find_sub, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | into => __PACKAGE__, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | as => $finder_name, | ||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | ▶ | sub new_from_caps { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_from_caps: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | my ( $self, %args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 4 | ▶ | if ( not exists $args{desired_capabilities} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | $args{desired_capabilities} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | return $self->new(%args); | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 38 | ▶ | sub DEMOLISH { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DEMOLISH: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 38 | my ( $self, $in_global_destruction ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 38 | ▶ | return if $$ != $self->pid; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 38 | ▶ | return if $in_global_destruction; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 38 | ▶ | $self->quit() if ( $self->auto_close && defined $self->session_id ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->auto_close and defined $self->session_id
MC/DC100%2/2
$self->auto_close and defined $self->session_id
$self->auto_close
defined $self->session_id
Truth table100%3/3
A and B
A= $self->auto_closeB= defined $self->session_id
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | # We install an 'around' because we can catch more exceptions this way | ||||||||||||||||||||||||||||||||||||||||||
| 339 | # than simply wrapping the explicit croaks in _execute_command. | ||||||||||||||||||||||||||||||||||||||||||
| 340 | # @args should be fed to the handler to provide context | ||||||||||||||||||||||||||||||||||||||||||
| 341 | # return_value could be assigned from the handler if we want to allow the | ||||||||||||||||||||||||||||||||||||||||||
| 342 | # error_handler to handle the errors | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | 291 | ▶ | around '_execute_command' => sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | 291 | my $orig = shift; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 291 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | # copy @_ because it gets lost in the way | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 291 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 291 | my $return_value; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 291 | ▶ | try { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 291 | $return_value = $orig->( $self, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 19 | ▶ | catch { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 19 | ▶ | if ( $self->has_error_handler ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 1 | $return_value = $self->error_handler->( $self, $_, @args ); | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 18 | croak $_; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 291 | }; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 272 | return $return_value; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 26 | }; | |||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | # This is an internal method used the Driver & is not supposed to be used by | ||||||||||||||||||||||||||||||||||||||||||
| 366 | # end user. This method is used by Driver to set up all the parameters | ||||||||||||||||||||||||||||||||||||||||||
| 367 | # (url & JSON), send commands & receive processed response from the server. | ||||||||||||||||||||||||||||||||||||||||||
| 368 | sub _execute_command { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 290 | my ( $self, $res, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 290 | $res->{'session_id'} = $self->session_id; | |||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 290 | ▶ | print "Prepping $res->{command}\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | #webdriver 3 shims | ||||||||||||||||||||||||||||||||||||||||||
| 375 | return $self->{capabilities} | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 290 | ▶ | if $res->{command} eq 'getCapabilities' && $self->{capabilities}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$res->{"command"} eq "getCapabilities" and $self->{"capabilities"}
MC/DC100%2/2
$res->{"command"} eq "getCapabilities" and $self->{"capabilities"}
$res->{"command"} eq "getCapabilities"
$self->{"capabilities"}
Truth table100%3/3
A and B
A= $res->{"command"} eq "getCapabilities"B= $self->{"capabilities"}
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 290 | ▶ | $res->{ms} = $params->{ms} if $params->{ms}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 290 | ▶ | $res->{type} = $params->{type} if $params->{type}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | ▶ | $res->{text} = $params->{text} if $params->{text}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | $res->{using} = $params->{using} if $params->{using}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | 289 | ▶ | $res->{value} = $params->{value} if $params->{value}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | print "Executing $res->{command}\n" if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | my $resource = | ||||||||||||||||||||||||||||||||||||||||||
| 385 | $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | ? $self->commands_v3->get_params($res) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | : $self->commands->get_params($res); | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | #Fall-back to legacy if wd3 command doesn't exist | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ( !$resource && $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $resource and $self->{"is_wd3"}
MC/DC50%1/2
not $resource and $self->{"is_wd3"}
not $resource
$self->{"is_wd3"}
Truth table66%2/3
not(A) and B
A= not $resourceB= $self->{"is_wd3"}
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | print "Falling back to legacy selenium method for $res->{command}\n" | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if $self->{debug}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $resource = $self->commands->get_params($res); | |||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | #XXX InternetExplorerDriver quirks | ||||||||||||||||||||||||||||||||||||||||||
| 397 | 289 | ▶ | if ( $self->{is_wd3} && $self->browser_name eq 'internet explorer' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"is_wd3"} and $self->browser_name eq "internet explorer"
MC/DC0%0/2
$self->{"is_wd3"} and $self->browser_name eq "internet explorer"
$self->{"is_wd3"}
$self->browser_name eq "internet explorer"
Truth table66%2/3
A and B
A= $self->{"is_wd3"}B= $self->browser_name eq "internet explorer"
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 289 | delete $params->{ms}; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 289 | delete $params->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 289 | delete $resource->{payload}->{type}; | |||||||||||||||||||||||||||||||||||||||||
| 401 | 288 | my $oldvalue = delete $params->{'page load'}; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | $params->{pageLoad} = $oldvalue if $oldvalue; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | ▶ | if ($resource) { | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | ▶ | $params = {} unless $params; | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | my $resp = $self->remote_conn->request( $resource, $params ); | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | #In general, the parse_response for v3 is better, which is why we use it *even if* we are falling back. | ||||||||||||||||||||||||||||||||||||||||||
| 410 | return $self->commands_v3->parse_response( $res, $resp ) | ||||||||||||||||||||||||||||||||||||||||||
| 411 | ▶ | if $self->{is_wd3}; | |||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | return $self->commands->parse_response( $res, $resp ); | ||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 414 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 415 | #Tell the use about the offending setting. | ||||||||||||||||||||||||||||||||||||||||||
| 416 | croak "Couldn't retrieve command settings properly ".$res->{command}."\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 22 | ▶ | sub new_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_session: called CC=7 SCAR=20.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 422 | 22 | my ( $self, $extra_capabilities ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 22 | ▶ | $extra_capabilities ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$extra_capabilities ||= {}
MC/DC0%0/1
$extra_capabilities ||= {}
$extra_capabilities
Truth table50%1/2
A
A= $extra_capabilities
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 22 | ▶ | my $args = { | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->version // ""
MC/DC0%0/1
$self->version // ""
$self->version
Truth table50%1/2
A
A= $self->version
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 'desiredCapabilities' => { | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 'browserName' => $self->browser_name, | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 'platform' => $self->platform, | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 'javascriptEnabled' => $self->javascript, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 'version' => $self->version // '', | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 'acceptSslCerts' => $self->accept_ssl_certs, | ||||||||||||||||||||||||||||||||||||||||||
| 432 | %$extra_capabilities, | ||||||||||||||||||||||||||||||||||||||||||
| 433 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 434 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 22 | ▶ | $args->{'extra_capabilities'} = \%$extra_capabilities unless $FORCE_WD2; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 22 | ▶ | if ( defined $self->proxy ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | $args->{desiredCapabilities}->{proxy} = $self->proxy; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | 22 | ▶ | if ( $args->{desiredCapabilities}->{browserName} =~ /firefox/i | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$args->{"desiredCapabilities"}{"browserName"} =~ /firefox/i and $self->has_firefox_profile
MC/DC0%0/2
$args->{"desiredCapabilities"}{"browserName"} =~ /firefox/i and $self->has_firefox_profile
$args->{"desiredCapabilities"}{"browserName"} =~ /firefox/i
$self->has_firefox_profile
Truth table66%2/3
A and B
A= $args->{"desiredCapabilities"}{"browserName"} =~ /firefox/iB= $self->has_firefox_profile
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | && $self->has_firefox_profile ) | ||||||||||||||||||||||||||||||||||||||||||
| 443 | { | ||||||||||||||||||||||||||||||||||||||||||
| 444 | $args->{desiredCapabilities}->{firefox_profile} = | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | $self->firefox_profile->_encode; | |||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 22 | $self->_request_new_session($args); | |||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | 5 | ▶ | sub new_desired_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_desired_session: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 453 | 5 | my ( $self, $caps ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 5 | $self->_request_new_session( | |||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||
| 457 | desiredCapabilities => $caps | ||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 459 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 29 | ▶ | sub _request_new_session { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_request_new_session: called CC=37 SCAR=41.0
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 29 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | #XXX UGLY shim for webdriver3 | ||||||||||||||||||||||||||||||||||||||||||
| 466 | $args->{capabilities}->{alwaysMatch} = | ||||||||||||||||||||||||||||||||||||||||||
| 467 | 29 | clone( $args->{desiredCapabilities} ); | |||||||||||||||||||||||||||||||||||||||||
| 468 | 29 | my $cmap = $self->commands_v3->get_caps_map(); | |||||||||||||||||||||||||||||||||||||||||
| 469 | 29 | my $caps = $self->commands_v3->get_caps(); | |||||||||||||||||||||||||||||||||||||||||
| 470 | 29 | foreach my $cap ( keys( %{ $args->{capabilities}->{alwaysMatch} } ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | #Handle browser specific capabilities | ||||||||||||||||||||||||||||||||||||||||||
| 473 | 136 | ▶ | if ( exists( $args->{desiredCapabilities}->{browserName} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $args->{"desiredCapabilities"}{"browserName"} and $cap eq "extra_capabilities"
MC/DC50%1/2
exists $args->{"desiredCapabilities"}{"browserName"} and $cap eq "extra_capabilities"
exists $args->{"desiredCapabilities"}{"browserName"}
$cap eq "extra_capabilities"
Truth table66%2/3
A and B
A= exists $args->{"desiredCapabilities"}{"browserName"}B= $cap eq "extra_capabilities"
| |||||||||||||||||||||||||||||||||||||||||||
| 474 | && $cap eq 'extra_capabilities' ) | ||||||||||||||||||||||||||||||||||||||||||
| 475 | { | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 2 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | exists $args->{capabilities}->{alwaysMatch} | ||||||||||||||||||||||||||||||||||||||||||
| 479 | ->{'moz:firefoxOptions'}->{args} ) | ||||||||||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||||||||||
| 481 | $args->{capabilities}->{alwaysMatch}->{$cap}->{args} = | ||||||||||||||||||||||||||||||||||||||||||
| 482 | $args->{capabilities}->{alwaysMatch}->{'moz:firefoxOptions'} | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ->{args}; | |||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||
| 485 | $args->{capabilities}->{alwaysMatch}->{'moz:firefoxOptions'} = | ||||||||||||||||||||||||||||||||||||||||||
| 486 | $args->{capabilities}->{alwaysMatch}->{$cap} | ||||||||||||||||||||||||||||||||||||||||||
| 487 | 2 | ▶ | if $args->{desiredCapabilities}->{browserName} eq 'firefox'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | #XXX the chrome documentation is lies, you can't do this yet | ||||||||||||||||||||||||||||||||||||||||||
| 490 | #$args->{capabilities}->{alwaysMatch}->{'goog:chromeOptions'} = $args->{capabilities}->{alwaysMatch}->{$cap} if $args->{desiredCapabilities}->{browserName} eq 'chrome'; | ||||||||||||||||||||||||||||||||||||||||||
| 491 | #Does not appear there are any MSIE based options, so let's just let that be | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 136 | ▶ | if ( exists( $args->{desiredCapabilities}->{browserName} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
exists $args->{"desiredCapabilities"}{"browserName"} and $args->{"desiredCapabilities"}{"browserName"} eq "firefox" and $cap eq "firefox_profile"
exists $args->{"desiredCapabilities"}{"browserName"} and $args->{"desiredCapabilities"}{"browserName"} eq "firefox"
MC/DC66%2/3
exists $args->{"desiredCapabilities"}{"browserName"} and $args->{"desiredCapabilities"}{"browserName"} eq "firefox" and $cap eq "firefox_profile"
exists $args->{"desiredCapabilities"}{"browserName"}
$args->{"desiredCapabilities"}{"browserName"} eq "firefox"
$cap eq "firefox_profile"
Truth table75%3/4
A and B and C
A= exists $args->{"desiredCapabilities"}{"browserName"}B= $args->{"desiredCapabilities"}{"browserName"} eq "firefox"C= $cap eq "firefox_profile"
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | && $args->{desiredCapabilities}->{browserName} eq 'firefox' | ||||||||||||||||||||||||||||||||||||||||||
| 495 | && $cap eq 'firefox_profile' ) | ||||||||||||||||||||||||||||||||||||||||||
| 496 | { | ||||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | ref $args->{capabilities}->{alwaysMatch}->{$cap} eq | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 'Selenium::Firefox::Profile' ) | ||||||||||||||||||||||||||||||||||||||||||
| 500 | { | ||||||||||||||||||||||||||||||||||||||||||
| 501 | #XXX not sure if I need to keep a ref to the File::Temp::Tempdir object to prevent reaping | ||||||||||||||||||||||||||||||||||||||||||
| 502 | $args->{capabilities}->{alwaysMatch}->{'moz:firefoxOptions'} | ||||||||||||||||||||||||||||||||||||||||||
| 503 | ->{args} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 504 | '-profile', | ||||||||||||||||||||||||||||||||||||||||||
| 505 | $args->{capabilities}->{alwaysMatch}->{$cap}->{profile_dir} | ||||||||||||||||||||||||||||||||||||||||||
| 506 | ->dirname() | ||||||||||||||||||||||||||||||||||||||||||
| 507 | 1 | ]; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 136 | foreach my $newkey ( keys(%$cmap) ) { | |||||||||||||||||||||||||||||||||||||||||
| 511 | 479 | ▶ | if ( $newkey eq $cap ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 103 | ▶ | last if $cmap->{$newkey} eq $cap; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | $args->{capabilities}->{alwaysMatch}->{ $cmap->{$newkey} } = | ||||||||||||||||||||||||||||||||||||||||||
| 514 | 72 | $args->{capabilities}->{alwaysMatch}->{$cap}; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 72 | delete $args->{capabilities}->{alwaysMatch}->{$cap}; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 72 | last; | |||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||
| 519 | delete $args->{capabilities}->{alwaysMatch}->{$cap} | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 136 | ▶ | if !any { $_ eq $cap } @$caps; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | delete $args->{desiredCapabilities} | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 29 | ▶ | if $FORCE_WD3; #XXX fork working-around busted fallback in firefox | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | delete $args->{capabilities} | ||||||||||||||||||||||||||||||||||||||||||
| 525 | 29 | ▶ | if $FORCE_WD2; #XXX 'secret' feature to help the legacy unit tests to work | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | #Delete compatibility layer when using drivers directly | ||||||||||||||||||||||||||||||||||||||||||
| 528 | 29 | ▶ | if ( $self->isa('Selenium::Firefox') || $self->isa('Selenium::Chrome') || $self->isa('Selenium::Edge') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->isa("Selenium::Firefox") or $self->isa("Selenium::Chrome") or $self->isa("Selenium::Edge")
$self->isa("Selenium::Firefox") or $self->isa("Selenium::Chrome")
MC/DC33%1/3
$self->isa("Selenium::Firefox") or $self->isa("Selenium::Chrome") or $self->isa("Selenium::Edge")
$self->isa("Selenium::Firefox")
$self->isa("Selenium::Chrome")
$self->isa("Selenium::Edge")
Truth table50%2/4
A or B or C
A= $self->isa("Selenium::Firefox")B= $self->isa("Selenium::Chrome")C= $self->isa("Selenium::Edge")
| |||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | ▶ | if ( exists $args->{capabilities} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $args->{"capabilities"} and exists $args->{"capabilities"}{"alwaysMatch"}
MC/DC0%0/2
exists $args->{"capabilities"} and exists $args->{"capabilities"}{"alwaysMatch"}
exists $args->{"capabilities"}
exists $args->{"capabilities"}{"alwaysMatch"}
Truth table33%1/3
A and B
A= exists $args->{"capabilities"}B= exists $args->{"capabilities"}{"alwaysMatch"}
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | && exists $args->{capabilities}->{alwaysMatch} ) | ||||||||||||||||||||||||||||||||||||||||||
| 531 | { | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | delete $args->{capabilities}->{alwaysMatch}->{browserName}; | |||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | delete $args->{capabilities}->{alwaysMatch}->{browserVersion}; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | delete $args->{capabilities}->{alwaysMatch}->{platformName}; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | #Fix broken out of the box chrome because they hate the maintainers of their interfaces | ||||||||||||||||||||||||||||||||||||||||||
| 539 | 29 | ▶ | if ( $self->isa('Selenium::Chrome') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | if ( exists $args->{desiredCapabilities} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | $args->{desiredCapabilities}{'goog:chromeOptions'}{args} //= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$args->{"desiredCapabilities"}{"goog:chromeOptions"}{"args"} //= []
MC/DC0%0/1
$args->{"desiredCapabilities"}{"goog:chromeOptions"}{"args"} //= []
$args->{"desiredCapabilities"}{"goog:chromeOptions"}{"args"}
Truth table0%0/2
A
A= $args->{"desiredCapabilities"}{"goog:chromeOptions"}{"args"}
| |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | push(@{$args->{desiredCapabilities}{'goog:chromeOptions'}{args}}, qw{no-sandbox disable-dev-shm-usage}); | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | # Get actual status | ||||||||||||||||||||||||||||||||||||||||||
| 547 | 29 | $self->remote_conn->check_status(); | |||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | # command => 'newSession' to fool the tests of commands implemented | ||||||||||||||||||||||||||||||||||||||||||
| 550 | # TODO: rewrite the testing better, this is so fragile. | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 28 | my $resource_new_session = { | |||||||||||||||||||||||||||||||||||||||||
| 552 | method => $self->commands->get_method('newSession'), | ||||||||||||||||||||||||||||||||||||||||||
| 553 | url => $self->commands->get_url('newSession'), | ||||||||||||||||||||||||||||||||||||||||||
| 554 | no_content_success => | ||||||||||||||||||||||||||||||||||||||||||
| 555 | $self->commands->get_no_content_success('newSession'), | ||||||||||||||||||||||||||||||||||||||||||
| 556 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 557 | 28 | my $rc = $self->remote_conn; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 28 | my $resp = $rc->request( $resource_new_session, $args, ); | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 28 | ▶ | if ( $resp->{cmd_status} && $resp->{cmd_status} eq 'NOT OK' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$resp->{"cmd_status"} and $resp->{"cmd_status"} eq "NOT OK"
MC/DC0%0/2
$resp->{"cmd_status"} and $resp->{"cmd_status"} eq "NOT OK"
$resp->{"cmd_status"}
$resp->{"cmd_status"} eq "NOT OK"
Truth table33%1/3
A and B
A= $resp->{"cmd_status"}B= $resp->{"cmd_status"} eq "NOT OK"
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | croak "Could not obtain new session: ". $resp->{cmd_return}{message}; | |||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||
| 564 | 28 | ▶ | if ( ( defined $resp->{'sessionId'} ) && $resp->{'sessionId'} ne '' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $resp->{"sessionId"} and $resp->{"sessionId"} ne ""
MC/DC50%1/2
defined $resp->{"sessionId"} and $resp->{"sessionId"} ne ""
defined $resp->{"sessionId"}
$resp->{"sessionId"} ne ""
Truth table66%2/3
A and B
A= defined $resp->{"sessionId"}B= $resp->{"sessionId"} ne ""
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | 27 | $self->session_id( $resp->{'sessionId'} ); | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | my $error = 'Could not create new session'; | |||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | ▶ | if ( ref $resp->{cmd_return} eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | $error .= ': ' . $resp->{cmd_return}->{message}; | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $error .= ': ' . $resp->{cmd_return}; | |||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | croak $error; | |||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | #Webdriver 3 - best guess that this is 'whats goin on' | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 27 | ▶ | if ( ref $resp->{cmd_return} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"capabilities"}
MC/DC100%2/2
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"capabilities"}
ref $resp->{"cmd_return"} eq "HASH"
$resp->{"cmd_return"}{"capabilities"}
Truth table100%3/3
A and B
A= ref $resp->{"cmd_return"} eq "HASH"B= $resp->{"cmd_return"}{"capabilities"}
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | && $resp->{cmd_return}->{capabilities} ) | ||||||||||||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||||||||||||
| 583 | 2 | $self->{is_wd3} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 584 | 2 | $self->{emulate_jsonwire} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 585 | 2 | $self->{capabilities} = $resp->{cmd_return}->{capabilities}; | |||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | #XXX chromedriver DOES NOT FOLLOW SPEC! | ||||||||||||||||||||||||||||||||||||||||||
| 589 | 27 | ▶ | if ( ref $resp->{cmd_return} eq 'HASH' && $resp->{cmd_return}->{chrome} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"chrome"}
MC/DC100%2/2
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"chrome"}
ref $resp->{"cmd_return"} eq "HASH"
$resp->{"cmd_return"}{"chrome"}
Truth table100%3/3
A and B
A= ref $resp->{"cmd_return"} eq "HASH"B= $resp->{"cmd_return"}{"chrome"}
| |||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | ▶ | if ( defined $resp->{cmd_return}->{setWindowRect} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 591 | { #XXX i'm inferring we are wd3 based on the presence of this | ||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | $self->{is_wd3} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $self->{emulate_jsonwire} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | $self->{capabilities} = $resp->{cmd_return}; | |||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | #XXX unsurprisingly, neither does microsoft | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 27 | ▶ | if ( ref $resp->{cmd_return} eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"pageLoadStrategy"} and $self->browser_name eq "MicrosoftEdge"
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"pageLoadStrategy"}
MC/DC0%0/3
ref $resp->{"cmd_return"} eq "HASH" and $resp->{"cmd_return"}{"pageLoadStrategy"} and $self->browser_name eq "MicrosoftEdge"
ref $resp->{"cmd_return"} eq "HASH"
$resp->{"cmd_return"}{"pageLoadStrategy"}
$self->browser_name eq "MicrosoftEdge"
Truth table75%3/4
A and B and C
A= ref $resp->{"cmd_return"} eq "HASH"B= $resp->{"cmd_return"}{"pageLoadStrategy"}C= $self->browser_name eq "MicrosoftEdge"
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | && $resp->{cmd_return}->{pageLoadStrategy} | ||||||||||||||||||||||||||||||||||||||||||
| 601 | && $self->browser_name eq 'MicrosoftEdge' ) | ||||||||||||||||||||||||||||||||||||||||||
| 602 | { | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | $self->{is_wd3} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $self->{emulate_jsonwire} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $self->{capabilities} = $resp->{cmd_return}; | |||||||||||||||||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 27 | return ( $args, $resp ); | |||||||||||||||||||||||||||||||||||||||||
| 609 | } | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | sub is_webdriver_3 { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_webdriver_3: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | return $self->{is_wd3}; | |||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | ▶ | sub debug_on { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_on: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | $self->{debug} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | $self->remote_conn->debug(1); | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | sub debug_off { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
debug_off: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $self->{debug} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | $self->remote_conn->debug(0); | |||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | sub get_sessions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sessions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my $res = { 'command' => 'getSessions' }; | |||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | 1 | ▶ | sub status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 640 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 641 | 1 | my $res = { 'command' => 'status' }; | |||||||||||||||||||||||||||||||||||||||||
| 642 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 6 | ▶ | sub get_alert_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_alert_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 648 | 6 | my $res = { 'command' => 'getAlertText' }; | |||||||||||||||||||||||||||||||||||||||||
| 649 | 6 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | sub send_keys_to_active_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_keys_to_active_element: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my ( $self, @strings ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 658 | { | ||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | @strings = map { split( '', $_ ) } @strings; | |||||||||||||||||||||||||||||||||||||||||
| 660 | my @acts = map { | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ( | |||||||||||||||||||||||||||||||||||||||||
| 662 | { | ||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | type => 'keyDown', | |||||||||||||||||||||||||||||||||||||||||
| 664 | value => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 665 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | type => 'keyUp', | ||||||||||||||||||||||||||||||||||||||||||
| 668 | value => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||
| 670 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 671 | } @strings; | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $action = { | |||||||||||||||||||||||||||||||||||||||||
| 674 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 675 | { | ||||||||||||||||||||||||||||||||||||||||||
| 676 | id => 'key', | ||||||||||||||||||||||||||||||||||||||||||
| 677 | type => 'key', | ||||||||||||||||||||||||||||||||||||||||||
| 678 | actions => \@acts, | ||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||
| 680 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 681 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | return $self->general_action(%$action); | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $res = { 'command' => 'sendKeysToActiveElement' }; | |||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | my $params = { 'value' => \@strings, }; | |||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | sub send_keys_to_alert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_keys_to_alert: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | return shift->send_keys_to_prompt(@_); | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | ▶ | sub send_keys_to_prompt { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_keys_to_prompt: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | my ( $self, $keys ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 698 | 1 | my $res = { 'command' => 'sendKeysToPrompt' }; | |||||||||||||||||||||||||||||||||||||||||
| 699 | 1 | my $params = { 'text' => $keys }; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 1 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 6 | ▶ | sub accept_alert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept_alert: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | 6 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 706 | 6 | my $res = { 'command' => 'acceptAlert' }; | |||||||||||||||||||||||||||||||||||||||||
| 707 | 6 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||
| 711 | 3 | ▶ | sub dismiss_alert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dismiss_alert: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 712 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 713 | 3 | my $res = { 'command' => 'dismissAlert' }; | |||||||||||||||||||||||||||||||||||||||||
| 714 | 3 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | sub general_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
general_action: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my ( $self, %action ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | _queue_action(%action); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my $res = { 'command' => 'generalAction' }; | |||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my $out = $self->_execute_command( $res, \%CURRENT_ACTION_CHAIN ); | |||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | %CURRENT_ACTION_CHAIN = ( actions => [] ); | |||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | return $out; | |||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | sub _queue_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queue_action: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | my (%action) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | ▶ | if ( ref $action{actions} eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | foreach my $live_action ( @{ $action{actions} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | my $existing_action; | |||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | foreach my $global_action ( @{ $CURRENT_ACTION_CHAIN{actions} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | if ( $global_action->{id} eq $live_action->{id} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $existing_action = $global_action; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | if ($existing_action) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | push( | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | @{ $existing_action->{actions} }, | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | @{ $live_action->{actions} } | |||||||||||||||||||||||||||||||||||||||||
| 743 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 744 | } | ||||||||||||||||||||||||||||||||||||||||||
| 745 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | push( @{ $CURRENT_ACTION_CHAIN{actions} }, $live_action ); | |||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | 0 | ▶ | sub release_general_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
release_general_action: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | my $res = { 'command' => 'releaseGeneralAction' }; | |||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | %CURRENT_ACTION_CHAIN = ( actions => [] ); | |||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | sub mouse_move_to_location { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mouse_move_to_location: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | my ( $self, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | $params{element} = $params{element}{id} if exists $params{element}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 767 | { | ||||||||||||||||||||||||||||||||||||||||||
| 768 | 0 | my $origin = $params{element}; | |||||||||||||||||||||||||||||||||||||||||
| 769 | my $move_action = { | ||||||||||||||||||||||||||||||||||||||||||
| 770 | type => "pointerMove", | ||||||||||||||||||||||||||||||||||||||||||
| 771 | duration => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 772 | x => $params{xoffset} // 0, | ||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | ▶ | y => $params{yoffset} // 0, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$params{"xoffset"} // 0
$params{"yoffset"} // 0
MC/DC0%0/1
$params{"xoffset"} // 0
$params{"xoffset"}
MC/DC0%0/1
$params{"yoffset"} // 0
$params{"yoffset"}
Truth table0%0/2
A
A= $params{"xoffset"}
Truth table0%0/2
A
A= $params{"yoffset"}
| |||||||||||||||||||||||||||||||||||||||||||
| 774 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 775 | $move_action->{origin} = | ||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | { 'element-6066-11e4-a52e-4f735466cecf' => $origin } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 777 | if $origin; | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | _queue_action( | |||||||||||||||||||||||||||||||||||||||||
| 780 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 781 | { | ||||||||||||||||||||||||||||||||||||||||||
| 782 | type => "pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 783 | id => 'mouse', | ||||||||||||||||||||||||||||||||||||||||||
| 784 | "parameters" => { "pointerType" => "mouse" }, | ||||||||||||||||||||||||||||||||||||||||||
| 785 | actions => [$move_action], | ||||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 787 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 788 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | my $res = { 'command' => 'mouseMoveToLocation' }; | |||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | return $self->_execute_command( $res, \%params ); | |||||||||||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | 0 | ▶ | sub move_to { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
move_to: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | return shift->mouse_move_to_location(@_); | |||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 1 | ▶ | sub get_capabilities { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_capabilities: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 1 | my $res = { 'command' => 'getCapabilities' }; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | sub get_timeouts { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_timeouts: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $res = { 'command' => 'getTimeouts' }; | |||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | return $self->_execute_command( $res, {} ); | |||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | 1 | ▶ | sub set_timeout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_timeout: called CC=5 SCAR=28.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 817 | 1 | my ( $self, $type, $ms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 818 | 1 | ▶ | if ( not defined $type ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | croak "Expecting type"; | |||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||
| 821 | 1 | $ms = _coerce_timeout_ms($ms); | |||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | $type = 'pageLoad' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$type eq "page load" and $self->browser_name ne "MicrosoftEdge"
MC/DC0%0/2
$type eq "page load" and $self->browser_name ne "MicrosoftEdge"
$type eq "page load"
$self->browser_name ne "MicrosoftEdge"
Truth table0%0/3
A and B
A= $type eq "page load"B= $self->browser_name ne "MicrosoftEdge"
| |||||||||||||||||||||||||||||||||||||||||||
| 823 | if $type eq 'page load' | ||||||||||||||||||||||||||||||||||||||||||
| 824 | && $self->browser_name ne | ||||||||||||||||||||||||||||||||||||||||||
| 825 | 'MicrosoftEdge'; #XXX SHIM they changed the WC3 standard mid stream | ||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my $res = { 'command' => 'setTimeout' }; | |||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $params = { $type => $ms }; | |||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | #XXX edge still follows earlier versions of the WC3 standard | ||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | ▶ | if ( $self->browser_name eq 'MicrosoftEdge' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | $params->{ms} = $ms; | |||||||||||||||||||||||||||||||||||||||||
| 833 | 0 | $params->{type} = $type; | |||||||||||||||||||||||||||||||||||||||||
| 834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||
| 839 | 1 | ▶ | sub set_async_script_timeout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_async_script_timeout: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 840 | 1 | my ( $self, $ms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | ▶ | return $self->set_timeout( 'script', $ms ) if $self->{is_wd3}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | $ms = _coerce_timeout_ms($ms); | |||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | my $res = { 'command' => 'setAsyncScriptTimeout' }; | |||||||||||||||||||||||||||||||||||||||||
| 846 | 0 | my $params = { 'ms' => $ms }; | |||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||||||||||||
| 851 | 3 | ▶ | sub set_implicit_wait_timeout { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_implicit_wait_timeout: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 852 | 3 | my ( $self, $ms ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 853 | 3 | ▶ | return $self->set_timeout( 'implicit', $ms ) if $self->{is_wd3}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | 3 | $ms = _coerce_timeout_ms($ms); | |||||||||||||||||||||||||||||||||||||||||
| 856 | 2 | my $res = { 'command' => 'setImplicitWaitTimeout' }; | |||||||||||||||||||||||||||||||||||||||||
| 857 | 2 | my $params = { 'ms' => $ms }; | |||||||||||||||||||||||||||||||||||||||||
| 858 | 2 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||
| 862 | 1 | ▶ | sub pause { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 863 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 864 | 1 | ▶ | my $timeout = ( shift // 1000 ) * 1000; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // 1000
MC/DC0%0/1
shift() // 1000
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 865 | 1 | usleep($timeout); | |||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 870 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | my $res = { 'command' => 'close' }; | |||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||
| 876 | 27 | ▶ | sub quit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
quit: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 877 | 27 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 878 | 27 | my $res = { 'command' => 'quit' }; | |||||||||||||||||||||||||||||||||||||||||
| 879 | 27 | $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 880 | 27 | $self->session_id(undef); | |||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | sub get_current_window_handle { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_current_window_handle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | my $res = { 'command' => 'getCurrentWindowHandle' }; | |||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | 2 | ▶ | sub get_window_handles { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_window_handles: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 893 | 2 | my $res = { 'command' => 'getWindowHandles' }; | |||||||||||||||||||||||||||||||||||||||||
| 894 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | sub get_window_size { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_window_size: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my ( $self, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | my $res = { 'command' => 'getWindowSize', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 902 | $res = { 'command' => 'getWindowRect', handle => $window } | ||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | if $self->{is_wd3}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 905 | } | ||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | sub get_window_position { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_window_position: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | my ( $self, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | my $res = { 'command' => 'getWindowPosition', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 912 | $res = { 'command' => 'getWindowRect', handle => $window } | ||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | if $self->{is_wd3}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 915 | } | ||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | 2 | ▶ | sub get_current_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_current_url: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 919 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 920 | 2 | my $res = { 'command' => 'getCurrentUrl' }; | |||||||||||||||||||||||||||||||||||||||||
| 921 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | 0 | ▶ | sub navigate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
navigate: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | my ( $self, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 927 | 0 | $self->get($url); | |||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||
| 931 | 28 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 932 | 28 | my ( $self, $url ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | 28 | ▶ | if ( $self->has_base_url && $url !~ m|://| ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->has_base_url and not $url =~ m[://]
MC/DC100%2/2
$self->has_base_url and not $url =~ m[://]
$self->has_base_url
not $url =~ m[://]
Truth table100%3/3
A and not(B)
A= $self->has_base_urlB= not $url =~ m[://]
| |||||||||||||||||||||||||||||||||||||||||||
| 935 | 5 | $url =~ s|^/||; | |||||||||||||||||||||||||||||||||||||||||
| 936 | 5 | $url = $self->base_url . "/" . $url; | |||||||||||||||||||||||||||||||||||||||||
| 937 | } | ||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||
| 939 | 28 | my $res = { 'command' => 'get' }; | |||||||||||||||||||||||||||||||||||||||||
| 940 | 28 | my $params = { 'url' => $url }; | |||||||||||||||||||||||||||||||||||||||||
| 941 | 28 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 942 | } | ||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | 14 | ▶ | sub get_title { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_title: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 946 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 947 | 14 | my $res = { 'command' => 'getTitle' }; | |||||||||||||||||||||||||||||||||||||||||
| 948 | 14 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | 2 | ▶ | sub go_back { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
go_back: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 954 | 2 | my $res = { 'command' => 'goBack' }; | |||||||||||||||||||||||||||||||||||||||||
| 955 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||||||||||||||||
| 959 | 1 | ▶ | sub go_forward { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
go_forward: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 960 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 961 | 1 | my $res = { 'command' => 'goForward' }; | |||||||||||||||||||||||||||||||||||||||||
| 962 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 963 | } | ||||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | 1 | ▶ | sub refresh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 967 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 968 | 1 | my $res = { 'command' => 'refresh' }; | |||||||||||||||||||||||||||||||||||||||||
| 969 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||
| 973 | 10 | ▶ | sub has_javascript { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_javascript: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 974 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 975 | 10 | return int( $self->javascript ); | |||||||||||||||||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||||||||||||||||
| 979 | 2 | ▶ | sub execute_async_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_async_script: called CC=10 SCAR=26.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | 2 | my ( $self, $script, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 981 | 2 | ▶ | if ( $self->has_javascript ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 982 | 2 | ▶ | if ( not defined $script ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | croak 'No script provided'; | |||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||
| 985 | 2 | my $res = | |||||||||||||||||||||||||||||||||||||||||
| 986 | { 'command' => 'executeAsyncScript' . $self->_execute_script_suffix }; | ||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | # Check the args array if the elem obj is provided & replace it with | ||||||||||||||||||||||||||||||||||||||||||
| 989 | # JSON representation | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 2 | ▶ | for ( my $i = 0 ; $i < @args ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 2 | ▶ | if ( Scalar::Util::blessed( $args[$i] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($args[$i]) and $args[$i]->isa("Selenium::Remote::WebElement")
MC/DC50%1/2
builtin::blessed($args[$i]) and $args[$i]->isa("Selenium::Remote::WebElement")
builtin::blessed($args[$i])
$args[$i]->isa("Selenium::Remote::WebElement")
Truth table66%2/3
A and B
A= builtin::blessed($args[$i])B= $args[$i]->isa("Selenium::Remote::WebElement")
| |||||||||||||||||||||||||||||||||||||||||||
| 992 | and $args[$i]->isa('Selenium::Remote::WebElement') ) | ||||||||||||||||||||||||||||||||||||||||||
| 993 | { | ||||||||||||||||||||||||||||||||||||||||||
| 994 | 1 | ▶ | if ( $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 995 | $args[$i] = | ||||||||||||||||||||||||||||||||||||||||||
| 996 | { 'element-6066-11e4-a52e-4f735466cecf' => | ||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ( $args[$i] )->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | 1 | $args[$i] = { 'ELEMENT' => ( $args[$i] )->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 2 | my $params = { 'script' => $script, 'args' => \@args }; | |||||||||||||||||||||||||||||||||||||||||
| 1006 | 2 | my $ret = $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | # replace any ELEMENTS with WebElement | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 2 | ▶ | if ( ref($ret) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $ret and ref $ret eq "HASH" and $self->_looks_like_element($ret)
ref $ret and ref $ret eq "HASH"
MC/DC0%0/3
ref $ret and ref $ret eq "HASH" and $self->_looks_like_element($ret)
ref $ret
ref $ret eq "HASH"
$self->_looks_like_element($ret)
Truth table25%1/4
A and B and C
A= ref $retB= ref $ret eq "HASH"C= $self->_looks_like_element($ret)
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | and ( ref($ret) eq 'HASH' ) | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | and $self->_looks_like_element($ret) ) | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | 2 | $ret = $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1014 | id => $ret, | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1017 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1018 | 2 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | 0 | croak 'Javascript is not enabled on remote driver instance.'; | |||||||||||||||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||
| 1026 | 8 | ▶ | sub execute_script { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_script: called CC=7 SCAR=20.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1027 | 8 | my ( $self, $script, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1028 | 8 | ▶ | if ( $self->has_javascript ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | 8 | ▶ | if ( not defined $script ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1030 | 0 | croak 'No script provided'; | |||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | 8 | my $res = | |||||||||||||||||||||||||||||||||||||||||
| 1033 | { 'command' => 'executeScript' . $self->_execute_script_suffix }; | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||
| 1035 | # Check the args array if the elem obj is provided & replace it with | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | # JSON representation | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | 8 | ▶ | for ( my $i = 0 ; $i < @args ; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 2 | ▶ | if ( Scalar::Util::blessed( $args[$i] ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($args[$i]) and $args[$i]->isa("Selenium::Remote::WebElement")
MC/DC50%1/2
builtin::blessed($args[$i]) and $args[$i]->isa("Selenium::Remote::WebElement")
builtin::blessed($args[$i])
$args[$i]->isa("Selenium::Remote::WebElement")
Truth table66%2/3
A and B
A= builtin::blessed($args[$i])B= $args[$i]->isa("Selenium::Remote::WebElement")
| |||||||||||||||||||||||||||||||||||||||||||
| 1039 | and $args[$i]->isa('Selenium::Remote::WebElement') ) | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1041 | 1 | ▶ | if ( $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1042 | $args[$i] = | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | { 'element-6066-11e4-a52e-4f735466cecf' => | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | ( $args[$i] )->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | 1 | $args[$i] = { 'ELEMENT' => ( $args[$i] )->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||
| 1052 | 8 | my $params = { 'script' => $script, 'args' => [@args] }; | |||||||||||||||||||||||||||||||||||||||||
| 1053 | 8 | my $ret = $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||||||||||||||||
| 1055 | 8 | return $self->_convert_to_webelement($ret); | |||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | croak 'Javascript is not enabled on remote driver instance.'; | |||||||||||||||||||||||||||||||||||||||||
| 1059 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||
| 1062 | # _looks_like_element | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | # An internal method to check if a return value might be an element | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 5 | ▶ | sub _looks_like_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_looks_like_element: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 5 | my ( $self, $maybe_element ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1067 | |||||||||||||||||||||||||||||||||||||||||||
| 1068 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 1069 | exists $maybe_element->{ELEMENT} | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | 5 | ▶ | or exists $maybe_element->{'element-6066-11e4-a52e-4f735466cecf'} | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
exists $maybe_element->{'ELEMENT'} || exists $maybe_element->{'element-6066-11e4-a52e-4f735466cecf'}
MC/DC0%0/2
exists $maybe_element->{'ELEMENT'} || exists $maybe_element->{'element-6066-11e4-a52e-4f735466cecf'}
exists $maybe_element->{'ELEMENT'}
exists $maybe_element->{'element-6066-11e4-a52e-4f735466cecf'}
Truth table33%1/3
A || B
A= exists $maybe_element->{'ELEMENT'}B= exists $maybe_element->{'element-6066-11e4-a52e-4f735466cecf'}
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||
| 1074 | # _convert_to_webelement | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | # An internal method used to traverse a data structure | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | # and convert any ELEMENTS with WebElements | ||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||
| 1078 | 9 | ▶ | sub _convert_to_webelement { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_convert_to_webelement: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | 9 | my ( $self, $ret ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||||||||||||||||
| 1081 | 9 | ▶ | if ( ref($ret) and ( ref($ret) eq 'HASH' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $ret and ref $ret eq "HASH"
MC/DC100%2/2
ref $ret and ref $ret eq "HASH"
ref $ret
ref $ret eq "HASH"
Truth table100%3/3
A and B
A= ref $retB= ref $ret eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 1082 | 3 | ▶ | if ( $self->_looks_like_element($ret) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | # replace an ELEMENT with WebElement | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | 3 | return $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1086 | id => $ret, | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1088 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||
| 1091 | 0 | my %hash; | |||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | foreach my $key ( keys %$ret ) { | |||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $hash{$key} = $self->_convert_to_webelement( $ret->{$key} ); | |||||||||||||||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||||||||||||||||
| 1098 | 6 | ▶ | if ( ref($ret) and ( ref($ret) eq 'ARRAY' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $ret and ref $ret eq "ARRAY"
MC/DC50%1/2
ref $ret and ref $ret eq "ARRAY"
ref $ret
ref $ret eq "ARRAY"
Truth table66%2/3
A and B
A= ref $retB= ref $ret eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 1099 | 1 | my @array = map { $self->_convert_to_webelement($_) } @$ret; | |||||||||||||||||||||||||||||||||||||||||
| 1100 | 1 | return \@array; | |||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||||||||||||||||
| 1103 | 5 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||
| 1106 | |||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | ▶ | sub screenshot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
screenshot: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | my ($self, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1109 | 0 | ▶ | $params //= { full => 0 }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$params //= {"full", 0}
MC/DC0%0/1
$params //= {"full", 0}
$params
Truth table0%0/2
A
A= $params
| |||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||
| 1111 | 0 | ▶ | croak "Full page screenshot only supported on geckodriver" if $params->{full} && ( $self->{browser_name} ne 'firefox' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$params->{"full"} and $self->{"browser_name"} ne "firefox"
MC/DC0%0/2
$params->{"full"} and $self->{"browser_name"} ne "firefox"
$params->{"full"}
$self->{"browser_name"} ne "firefox"
Truth table0%0/3
A and B
A= $params->{"full"}B= $self->{"browser_name"} ne "firefox"
| |||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | my $res = { 'command' => $params->{'full'} == 1 ? 'mozScreenshotFull' : 'screenshot' }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1116 | |||||||||||||||||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | ▶ | sub capture_screenshot { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
capture_screenshot: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1119 | 0 | my ( $self, $filename, $params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1120 | 0 | ▶ | croak '$filename is required' unless $filename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | open( my $fh, '>', $filename ); | |||||||||||||||||||||||||||||||||||||||||
| 1123 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||
| 1124 | 0 | print $fh MIME::Base64::decode_base64( $self->screenshot($params) ); | |||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | CORE::close $fh; | |||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||
| 1129 | |||||||||||||||||||||||||||||||||||||||||||
| 1130 | #TODO emulate behavior on wd3? | ||||||||||||||||||||||||||||||||||||||||||
| 1131 | #grep { eval { Selenium::Remote::Driver->new( browser => $_ ) } } (qw{firefox MicrosoftEdge chrome opera safari htmlunit iphone phantomjs},'internet_explorer'); | ||||||||||||||||||||||||||||||||||||||||||
| 1132 | #might do the trick | ||||||||||||||||||||||||||||||||||||||||||
| 1133 | 1 | ▶ | sub available_engines { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
available_engines: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1134 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1135 | 1 | my $res = { 'command' => 'availableEngines' }; | |||||||||||||||||||||||||||||||||||||||||
| 1136 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||
| 1139 | |||||||||||||||||||||||||||||||||||||||||||
| 1140 | 1 | ▶ | sub switch_to_frame { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
switch_to_frame: called CC=4 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1141 | 1 | my ( $self, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||
| 1143 | 1 | my $json_null = JSON::null; | |||||||||||||||||||||||||||||||||||||||||
| 1144 | 1 | my $params; | |||||||||||||||||||||||||||||||||||||||||
| 1145 | 1 | ▶ | $id = ( defined $id ) ? $id : $json_null; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1146 | |||||||||||||||||||||||||||||||||||||||||||
| 1147 | 1 | my $res = { 'command' => 'switchToFrame' }; | |||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||
| 1149 | 1 | ▶ | if ( ref $id eq $self->webelement_class ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | ▶ | if ( $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1151 | $params = | ||||||||||||||||||||||||||||||||||||||||||
| 1152 | { 'id' => | ||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | { 'element-6066-11e4-a52e-4f735466cecf' => $id->{'id'} } }; | |||||||||||||||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1155 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | $params = { 'id' => { 'ELEMENT' => $id->{'id'} } }; | |||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1159 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1160 | 1 | $params = { 'id' => $id }; | |||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1162 | 1 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | ▶ | sub switch_to_parent_frame { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
switch_to_parent_frame: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1167 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1168 | 0 | my $res = { 'command' => 'switchToParentFrame' }; | |||||||||||||||||||||||||||||||||||||||||
| 1169 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||||||||||||||||
| 1173 | 4 | ▶ | sub switch_to_window { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
switch_to_window: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1174 | 4 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1175 | 4 | ▶ | if ( not defined $name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | return 'Window name not provided'; | |||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1178 | 4 | my $res = { 'command' => 'switchToWindow' }; | |||||||||||||||||||||||||||||||||||||||||
| 1179 | 4 | my $params = { 'name' => $name, 'handle' => $name }; | |||||||||||||||||||||||||||||||||||||||||
| 1180 | 4 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||
| 1184 | 0 | ▶ | sub set_window_position { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_window_position: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | my ( $self, $x, $y, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1186 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1187 | 0 | ▶ | if ( not defined $x and not defined $y ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $x or defined $y
MC/DC0%0/2
defined $x or defined $y
defined $x
defined $y
Truth table0%0/3
A or B
A= defined $xB= defined $y
| |||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | croak "X & Y co-ordinates are required"; | |||||||||||||||||||||||||||||||||||||||||
| 1189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1190 | 0 | ▶ | croak qq{Error: In set_window_size, argument x "$x" isn't numeric} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1191 | unless Scalar::Util::looks_like_number($x); | ||||||||||||||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | croak qq{Error: In set_window_size, argument y "$y" isn't numeric} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1193 | unless Scalar::Util::looks_like_number($y); | ||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | $x += | |||||||||||||||||||||||||||||||||||||||||
| 1195 | 0; # convert to numeric if a string, otherwise they'll be sent as strings | ||||||||||||||||||||||||||||||||||||||||||
| 1196 | 0 | $y += 0; | |||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | my $res = { 'command' => 'setWindowPosition', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | my $params = { 'x' => $x, 'y' => $y }; | |||||||||||||||||||||||||||||||||||||||||
| 1199 | 0 | ▶ | if ( $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $res = { 'command' => 'setWindowRect', handle => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | my $ret = $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | ▶ | return $ret ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | ▶ | sub set_window_size { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_window_size: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1208 | 0 | my ( $self, $height, $width, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1210 | 0 | ▶ | if ( not defined $height and not defined $width ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $height or defined $width
MC/DC0%0/2
defined $height or defined $width
defined $height
defined $width
Truth table0%0/3
A or B
A= defined $heightB= defined $width
| |||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | croak "height & width of browser are required"; | |||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1213 | 0 | ▶ | croak qq{Error: In set_window_size, argument height "$height" isn't numeric} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1214 | unless Scalar::Util::looks_like_number($height); | ||||||||||||||||||||||||||||||||||||||||||
| 1215 | 0 | ▶ | croak qq{Error: In set_window_size, argument width "$width" isn't numeric} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1216 | unless Scalar::Util::looks_like_number($width); | ||||||||||||||||||||||||||||||||||||||||||
| 1217 | 0 | $height += | |||||||||||||||||||||||||||||||||||||||||
| 1218 | 0; # convert to numeric if a string, otherwise they'll be sent as strings | ||||||||||||||||||||||||||||||||||||||||||
| 1219 | 0 | $width += 0; | |||||||||||||||||||||||||||||||||||||||||
| 1220 | 0 | my $res = { 'command' => 'setWindowSize', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1221 | 0 | my $params = { 'height' => $height, 'width' => $width }; | |||||||||||||||||||||||||||||||||||||||||
| 1222 | 0 | ▶ | if ( $self->{is_wd3} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1223 | 0 | $res = { 'command' => 'setWindowRect', handle => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1224 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1225 | 0 | my $ret = $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1226 | 0 | ▶ | return $ret ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | ▶ | sub maximize_window { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
maximize_window: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1231 | 0 | my ( $self, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||
| 1233 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1234 | 0 | my $res = { 'command' => 'maximizeWindow', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1235 | 0 | my $ret = $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1236 | 0 | ▶ | return $ret ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||
| 1240 | 0 | ▶ | sub minimize_window { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minimize_window: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1241 | 0 | my ( $self, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | my $res = { 'command' => 'minimizeWindow', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1244 | 0 | my $ret = $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | ▶ | return $ret ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | ▶ | sub fullscreen_window { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fullscreen_window: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my ( $self, $window ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | ▶ | $window = ( defined $window ) ? $window : 'current'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | my $res = { 'command' => 'fullscreenWindow', 'window_handle' => $window }; | |||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | my $ret = $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | ▶ | return $ret ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||||||||||||
| 1258 | 4 | ▶ | sub get_all_cookies { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_cookies: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1259 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1260 | 4 | my $res = { 'command' => 'getAllCookies' }; | |||||||||||||||||||||||||||||||||||||||||
| 1261 | 4 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1263 | |||||||||||||||||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||||||||||||||||
| 1265 | 1 | ▶ | sub add_cookie { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_cookie: called CC=8 SCAR=23.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1266 | 1 | my ( $self, $name, $value, $path, $domain, $secure, $httponly, $expiry ) = | |||||||||||||||||||||||||||||||||||||||||
| 1267 | @_; | ||||||||||||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||||||||||||
| 1269 | 1 | ▶ | if ( ( not defined $name ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and defined $value
MC/DC0%0/2
defined $name and defined $value
defined $name
defined $value
Truth table33%1/3
A and B
A= defined $nameB= defined $value
| |||||||||||||||||||||||||||||||||||||||||||
| 1270 | || ( not defined $value ) ) | ||||||||||||||||||||||||||||||||||||||||||
| 1271 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1272 | 0 | croak "Missing parameters"; | |||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||||||||||||||||
| 1275 | 1 | my $res = { 'command' => 'addCookie' }; | |||||||||||||||||||||||||||||||||||||||||
| 1276 | 1 | my $json_false = JSON::false; | |||||||||||||||||||||||||||||||||||||||||
| 1277 | 1 | my $json_true = JSON::true; | |||||||||||||||||||||||||||||||||||||||||
| 1278 | 1 | ▶ | $secure = ( defined $secure && $secure ) ? $json_true : $json_false; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $secure and $secure
MC/DC0%0/2
defined $secure and $secure
defined $secure
$secure
Truth table33%1/3
A and B
A= defined $secureB= $secure
| |||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||
| 1280 | 1 | my $params = { | |||||||||||||||||||||||||||||||||||||||||
| 1281 | 'cookie' => { | ||||||||||||||||||||||||||||||||||||||||||
| 1282 | 'name' => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 1283 | 'value' => $value, | ||||||||||||||||||||||||||||||||||||||||||
| 1284 | 'path' => $path, | ||||||||||||||||||||||||||||||||||||||||||
| 1285 | 'secure' => $secure, | ||||||||||||||||||||||||||||||||||||||||||
| 1286 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1287 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1288 | 1 | ▶ | $params->{cookie}->{domain} = $domain if $domain; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1289 | 1 | ▶ | $params->{cookie}->{'httponly'} = $httponly if $httponly; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1290 | 1 | ▶ | $params->{cookie}->{'expiry'} = $expiry if $expiry; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||
| 1292 | 1 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1294 | |||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||
| 1296 | 2 | ▶ | sub delete_all_cookies { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_all_cookies: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1297 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1298 | 2 | my $res = { 'command' => 'deleteAllCookies' }; | |||||||||||||||||||||||||||||||||||||||||
| 1299 | 2 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1300 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||
| 1302 | |||||||||||||||||||||||||||||||||||||||||||
| 1303 | 0 | ▶ | sub get_cookie_named { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cookie_named: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1304 | 0 | my ( $self, $cookie_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1305 | 0 | my $res = { 'command' => 'getCookieNamed', 'name' => $cookie_name }; | |||||||||||||||||||||||||||||||||||||||||
| 1306 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1308 | |||||||||||||||||||||||||||||||||||||||||||
| 1309 | |||||||||||||||||||||||||||||||||||||||||||
| 1310 | 1 | ▶ | sub delete_cookie_named { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_cookie_named: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1311 | 1 | my ( $self, $cookie_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1312 | 1 | ▶ | if ( not defined $cookie_name ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | croak "Cookie name not provided"; | |||||||||||||||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1315 | 1 | my $res = { 'command' => 'deleteCookieNamed', 'name' => $cookie_name }; | |||||||||||||||||||||||||||||||||||||||||
| 1316 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1318 | |||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||
| 1320 | 13 | ▶ | sub get_page_source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_page_source: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1321 | 13 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1322 | 13 | my $res = { 'command' => 'getPageSource' }; | |||||||||||||||||||||||||||||||||||||||||
| 1323 | 13 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1324 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1325 | |||||||||||||||||||||||||||||||||||||||||||
| 1326 | |||||||||||||||||||||||||||||||||||||||||||
| 1327 | 67 | ▶ | sub find_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_element: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1328 | 67 | my ( $self, $query, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1329 | 67 | ▶ | if ( not defined $query ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | croak 'Search string to find element not provided.'; | |||||||||||||||||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||
| 1333 | 67 | my $res = { 'command' => 'findElement' }; | |||||||||||||||||||||||||||||||||||||||||
| 1334 | 67 | my $params = $self->_build_find_params( $method, $query ); | |||||||||||||||||||||||||||||||||||||||||
| 1335 | 67 | my $ret_data = eval { $self->_execute_command( $res, $params ); }; | |||||||||||||||||||||||||||||||||||||||||
| 1336 | 67 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1337 | 12 | ▶ | if ( $@ =~ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1338 | /(An element could not be located on the page using the given search parameters)/ | ||||||||||||||||||||||||||||||||||||||||||
| 1339 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1340 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1341 | # give details on what element wasn't found | ||||||||||||||||||||||||||||||||||||||||||
| 1342 | 11 | $@ = "$1: $query,$params->{using}"; | |||||||||||||||||||||||||||||||||||||||||
| 1343 | 11 | local @CARP_NOT = ( "Selenium::Remote::Driver", @CARP_NOT ); | |||||||||||||||||||||||||||||||||||||||||
| 1344 | 11 | croak $@; | |||||||||||||||||||||||||||||||||||||||||
| 1345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1346 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1347 | # re throw if the exception wasn't what we expected | ||||||||||||||||||||||||||||||||||||||||||
| 1348 | 1 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 1349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1351 | 55 | return $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1352 | id => $ret_data, | ||||||||||||||||||||||||||||||||||||||||||
| 1353 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1354 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||||||||||||||||
| 1358 | 6 | ▶ | sub find_elements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_elements: called CC=6 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1359 | 6 | my ( $self, $query, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1360 | 6 | ▶ | if ( not defined $query ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1361 | 0 | croak 'Search string to find element not provided.'; | |||||||||||||||||||||||||||||||||||||||||
| 1362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1363 | |||||||||||||||||||||||||||||||||||||||||||
| 1364 | 6 | my $res = { 'command' => 'findElements' }; | |||||||||||||||||||||||||||||||||||||||||
| 1365 | 6 | my $params = $self->_build_find_params( $method, $query ); | |||||||||||||||||||||||||||||||||||||||||
| 1366 | 6 | my $ret_data = eval { $self->_execute_command( $res, $params ); }; | |||||||||||||||||||||||||||||||||||||||||
| 1367 | 6 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1368 | 0 | ▶ | if ( $@ =~ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1369 | /(An element could not be located on the page using the given search parameters)/ | ||||||||||||||||||||||||||||||||||||||||||
| 1370 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1371 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1372 | # give details on what element wasn't found | ||||||||||||||||||||||||||||||||||||||||||
| 1373 | 0 | $@ = "$1: $query,$params->{using}"; | |||||||||||||||||||||||||||||||||||||||||
| 1374 | 0 | local @CARP_NOT = ( "Selenium::Remote::Driver", @CARP_NOT ); | |||||||||||||||||||||||||||||||||||||||||
| 1375 | 0 | croak $@; | |||||||||||||||||||||||||||||||||||||||||
| 1376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1377 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1378 | # re throw if the exception wasn't what we expected | ||||||||||||||||||||||||||||||||||||||||||
| 1379 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 1380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1382 | 6 | my $elem_obj_arr = []; | |||||||||||||||||||||||||||||||||||||||||
| 1383 | 6 | foreach (@$ret_data) { | |||||||||||||||||||||||||||||||||||||||||
| 1384 | 6 | push( | |||||||||||||||||||||||||||||||||||||||||
| 1385 | @$elem_obj_arr, | ||||||||||||||||||||||||||||||||||||||||||
| 1386 | $self->webelement_class->new( | ||||||||||||||||||||||||||||||||||||||||||
| 1387 | id => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 1388 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1389 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1390 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1392 | 4 | ▶ | return wantarray ? @{$elem_obj_arr} : $elem_obj_arr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1394 | |||||||||||||||||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||||||||||||||||
| 1396 | 4 | ▶ | sub find_child_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_child_element: called CC=5 SCAR=18.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1397 | 4 | my ( $self, $elem, $query, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1398 | 4 | ▶ | if ( ( not defined $elem ) || ( not defined $query ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $elem and defined $query
MC/DC50%1/2
defined $elem and defined $query
defined $elem
defined $query
Truth table66%2/3
A and B
A= defined $elemB= defined $query
| |||||||||||||||||||||||||||||||||||||||||||
| 1399 | 1 | croak "Missing parameters"; | |||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1401 | 3 | my $res = { 'command' => 'findChildElement', 'id' => $elem->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 1402 | 3 | my $params = $self->_build_find_params( $method, $query ); | |||||||||||||||||||||||||||||||||||||||||
| 1403 | 3 | my $ret_data = eval { $self->_execute_command( $res, $params ); }; | |||||||||||||||||||||||||||||||||||||||||
| 1404 | 3 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | ▶ | if ( $@ =~ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1406 | /(An element could not be located on the page using the given search parameters)/ | ||||||||||||||||||||||||||||||||||||||||||
| 1407 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1408 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1409 | # give details on what element wasn't found | ||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | $@ = "$1: $query,$params->{using}"; | |||||||||||||||||||||||||||||||||||||||||
| 1411 | 0 | local @CARP_NOT = ( "Selenium::Remote::Driver", @CARP_NOT ); | |||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | croak $@; | |||||||||||||||||||||||||||||||||||||||||
| 1413 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1414 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1415 | # re throw if the exception wasn't what we expected | ||||||||||||||||||||||||||||||||||||||||||
| 1416 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 1417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1419 | 3 | return $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1420 | id => $ret_data, | ||||||||||||||||||||||||||||||||||||||||||
| 1421 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1422 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1423 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||
| 1426 | 2 | ▶ | sub find_child_elements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_child_elements: called CC=7 SCAR=24.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1427 | 2 | my ( $self, $elem, $query, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1428 | 2 | ▶ | if ( ( not defined $elem ) || ( not defined $query ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $elem and defined $query
MC/DC0%0/2
defined $elem and defined $query
defined $elem
defined $query
Truth table33%1/3
A and B
A= defined $elemB= defined $query
| |||||||||||||||||||||||||||||||||||||||||||
| 1429 | 0 | croak "Missing parameters"; | |||||||||||||||||||||||||||||||||||||||||
| 1430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||
| 1432 | 2 | my $res = { 'command' => 'findChildElements', 'id' => $elem->{id} }; | |||||||||||||||||||||||||||||||||||||||||
| 1433 | 2 | my $params = $self->_build_find_params( $method, $query ); | |||||||||||||||||||||||||||||||||||||||||
| 1434 | 2 | my $ret_data = eval { $self->_execute_command( $res, $params ); }; | |||||||||||||||||||||||||||||||||||||||||
| 1435 | 2 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1436 | 0 | ▶ | if ( $@ =~ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1437 | /(An element could not be located on the page using the given search parameters)/ | ||||||||||||||||||||||||||||||||||||||||||
| 1438 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 1439 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1440 | # give details on what element wasn't found | ||||||||||||||||||||||||||||||||||||||||||
| 1441 | 0 | $@ = "$1: $query,$params->{using}"; | |||||||||||||||||||||||||||||||||||||||||
| 1442 | 0 | local @CARP_NOT = ( "Selenium::Remote::Driver", @CARP_NOT ); | |||||||||||||||||||||||||||||||||||||||||
| 1443 | 0 | croak $@; | |||||||||||||||||||||||||||||||||||||||||
| 1444 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1445 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1446 | # re throw if the exception wasn't what we expected | ||||||||||||||||||||||||||||||||||||||||||
| 1447 | 0 | die $@; | |||||||||||||||||||||||||||||||||||||||||
| 1448 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1449 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1450 | 2 | my $elem_obj_arr = []; | |||||||||||||||||||||||||||||||||||||||||
| 1451 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1452 | 2 | foreach (@$ret_data) { | |||||||||||||||||||||||||||||||||||||||||
| 1453 | 6 | $elem_obj_arr->[$i] = $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1454 | id => $_, | ||||||||||||||||||||||||||||||||||||||||||
| 1455 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1456 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1457 | 6 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 1458 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1459 | 0 | ▶ | return wantarray ? @{$elem_obj_arr} : $elem_obj_arr; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1461 | |||||||||||||||||||||||||||||||||||||||||||
| 1462 | |||||||||||||||||||||||||||||||||||||||||||
| 1463 | 78 | ▶ | sub _build_find_params { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_find_params: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||
| 1464 | 78 | my ( $self, $method, $query ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||||||||||||||||
| 1466 | 78 | my $using = $self->_build_using($method); | |||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||
| 1468 | # geckodriver doesn't accept name as a valid selector | ||||||||||||||||||||||||||||||||||||||||||
| 1469 | 78 | ▶ | if ( $self->isa('Selenium::Firefox') && $using eq 'name' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->isa("Selenium::Firefox") and $using eq "name"
MC/DC0%0/2
$self->isa("Selenium::Firefox") and $using eq "name"
$self->isa("Selenium::Firefox")
$using eq "name"
Truth table33%1/3
A and B
A= $self->isa("Selenium::Firefox")B= $using eq "name"
| |||||||||||||||||||||||||||||||||||||||||||
| 1470 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 1471 | 0 | using => 'css selector', | |||||||||||||||||||||||||||||||||||||||||
| 1472 | value => qq{[name="$query"]} | ||||||||||||||||||||||||||||||||||||||||||
| 1473 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1475 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1476 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 1477 | 78 | using => $using, | |||||||||||||||||||||||||||||||||||||||||
| 1478 | value => $query | ||||||||||||||||||||||||||||||||||||||||||
| 1479 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||||||||||||||||
| 1483 | 78 | ▶ | sub _build_using { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_using: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||
| 1484 | 78 | my ( $self, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1485 | |||||||||||||||||||||||||||||||||||||||||||
| 1486 | 78 | ▶ | if ($method) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1487 | 69 | ▶ | if ( $self->FINDERS->{$method} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1488 | 69 | return $self->FINDERS->{$method}; | |||||||||||||||||||||||||||||||||||||||||
| 1489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1490 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1491 | croak 'Bad method, expected: ' | ||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | . join( ', ', keys %{ $self->FINDERS } ) | |||||||||||||||||||||||||||||||||||||||||
| 1493 | . ", got $method"; | ||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1495 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1496 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1497 | 9 | return $self->default_finder; | |||||||||||||||||||||||||||||||||||||||||
| 1498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||||||||||||||||
| 1501 | 1 | ▶ | sub get_active_element { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_active_element: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1502 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1503 | 1 | my $res = { 'command' => 'getActiveElement' }; | |||||||||||||||||||||||||||||||||||||||||
| 1504 | 1 | my $ret_data = eval { $self->_execute_command($res) }; | |||||||||||||||||||||||||||||||||||||||||
| 1505 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1506 | 0 | croak $@; | |||||||||||||||||||||||||||||||||||||||||
| 1507 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1508 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1509 | 1 | return $self->webelement_class->new( | |||||||||||||||||||||||||||||||||||||||||
| 1510 | id => $ret_data, | ||||||||||||||||||||||||||||||||||||||||||
| 1511 | driver => $self | ||||||||||||||||||||||||||||||||||||||||||
| 1512 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1515 | |||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | ▶ | sub cache_status { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_status: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1518 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1519 | 0 | my $res = { 'command' => 'cacheStatus' }; | |||||||||||||||||||||||||||||||||||||||||
| 1520 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||||||||||||||||
| 1523 | |||||||||||||||||||||||||||||||||||||||||||
| 1524 | 1 | ▶ | sub set_geolocation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_geolocation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1525 | 1 | my ( $self, %params ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1526 | 1 | my $res = { 'command' => 'setGeolocation' }; | |||||||||||||||||||||||||||||||||||||||||
| 1527 | 1 | return $self->_execute_command( $res, \%params ); | |||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1529 | |||||||||||||||||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||||||||||||||||
| 1531 | 0 | ▶ | sub get_geolocation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_geolocation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1532 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1533 | 0 | my $res = { 'command' => 'getGeolocation' }; | |||||||||||||||||||||||||||||||||||||||||
| 1534 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||||||||||||||||
| 1538 | 4 | ▶ | sub get_log { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_log: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1539 | 4 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1540 | 4 | my $res = { 'command' => 'getLog' }; | |||||||||||||||||||||||||||||||||||||||||
| 1541 | 4 | return $self->_execute_command( $res, { type => $type } ); | |||||||||||||||||||||||||||||||||||||||||
| 1542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||||||||||||||||
| 1545 | 1 | ▶ | sub get_log_types { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_log_types: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1546 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1547 | 1 | my $res = { 'command' => 'getLogTypes' }; | |||||||||||||||||||||||||||||||||||||||||
| 1548 | 1 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||||||||||||||||
| 1552 | 0 | ▶ | sub set_orientation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_orientation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1553 | 0 | my ( $self, $orientation ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1554 | 0 | my $res = { 'command' => 'setOrientation' }; | |||||||||||||||||||||||||||||||||||||||||
| 1555 | 0 | return $self->_execute_command( $res, { orientation => $orientation } ); | |||||||||||||||||||||||||||||||||||||||||
| 1556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1557 | |||||||||||||||||||||||||||||||||||||||||||
| 1558 | |||||||||||||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | sub get_orientation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_orientation: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1560 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1561 | 0 | my $res = { 'command' => 'getOrientation' }; | |||||||||||||||||||||||||||||||||||||||||
| 1562 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1563 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||
| 1565 | |||||||||||||||||||||||||||||||||||||||||||
| 1566 | 1 | ▶ | sub send_modifier { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_modifier: called CC=6 SCAR=24.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1567 | 1 | my ( $self, $modifier, $isdown ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1568 | 1 | ▶ | if ( $isdown =~ /(down|up)/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1569 | 1 | ▶ | $isdown = $isdown =~ /down/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||||||||||||
| 1572 | 1 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table33%1/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 1573 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 1574 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1575 | my $acts = [ | ||||||||||||||||||||||||||||||||||||||||||
| 1576 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1577 | type => $isdown ? 'keyDown' : 'keyUp', | ||||||||||||||||||||||||||||||||||||||||||
| 1578 | 0 | ▶ | value => KEYS->{ lc($modifier) }, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1579 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1580 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||||||||||||||||
| 1582 | 0 | my $action = { | |||||||||||||||||||||||||||||||||||||||||
| 1583 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1584 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1585 | id => 'key', | ||||||||||||||||||||||||||||||||||||||||||
| 1586 | type => 'key', | ||||||||||||||||||||||||||||||||||||||||||
| 1587 | actions => $acts, | ||||||||||||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1589 | ] | ||||||||||||||||||||||||||||||||||||||||||
| 1590 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1591 | 0 | _queue_action(%$action); | |||||||||||||||||||||||||||||||||||||||||
| 1592 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||
| 1595 | 1 | my $res = { 'command' => 'sendModifier' }; | |||||||||||||||||||||||||||||||||||||||||
| 1596 | 1 | my $params = { | |||||||||||||||||||||||||||||||||||||||||
| 1597 | value => $modifier, | ||||||||||||||||||||||||||||||||||||||||||
| 1598 | isdown => $isdown | ||||||||||||||||||||||||||||||||||||||||||
| 1599 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1600 | 1 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||||||||||||||||
| 1603 | |||||||||||||||||||||||||||||||||||||||||||
| 1604 | 0 | ▶ | sub compare_elements { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compare_elements: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1605 | 0 | my ( $self, $elem1, $elem2 ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1606 | my $res = { | ||||||||||||||||||||||||||||||||||||||||||
| 1607 | 'command' => 'elementEquals', | ||||||||||||||||||||||||||||||||||||||||||
| 1608 | 'id' => $elem1->{id}, | ||||||||||||||||||||||||||||||||||||||||||
| 1609 | 'other' => $elem2->{id} | ||||||||||||||||||||||||||||||||||||||||||
| 1610 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 1611 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1612 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1613 | |||||||||||||||||||||||||||||||||||||||||||
| 1614 | |||||||||||||||||||||||||||||||||||||||||||
| 1615 | 0 | ▶ | sub click { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
click: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1616 | 0 | my ( $self, $button, $append ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1617 | 0 | $button = _get_button($button); | |||||||||||||||||||||||||||||||||||||||||
| 1618 | |||||||||||||||||||||||||||||||||||||||||||
| 1619 | 0 | my $res = { 'command' => 'click' }; | |||||||||||||||||||||||||||||||||||||||||
| 1620 | 0 | my $params = { 'button' => $button }; | |||||||||||||||||||||||||||||||||||||||||
| 1621 | |||||||||||||||||||||||||||||||||||||||||||
| 1622 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 1623 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 1624 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1625 | 0 | $params = { | |||||||||||||||||||||||||||||||||||||||||
| 1626 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1627 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1628 | type => "pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 1629 | id => 'mouse', | ||||||||||||||||||||||||||||||||||||||||||
| 1630 | parameters => { "pointerType" => "mouse" }, | ||||||||||||||||||||||||||||||||||||||||||
| 1631 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1632 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1633 | type => "pointerDown", | ||||||||||||||||||||||||||||||||||||||||||
| 1634 | duration => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1635 | button => $button, | ||||||||||||||||||||||||||||||||||||||||||
| 1636 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1637 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1638 | type => "pointerUp", | ||||||||||||||||||||||||||||||||||||||||||
| 1639 | duration => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1640 | button => $button, | ||||||||||||||||||||||||||||||||||||||||||
| 1641 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1642 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1643 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1644 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1645 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1646 | 0 | ▶ | if ($append) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1647 | 0 | _queue_action(%$params); | |||||||||||||||||||||||||||||||||||||||||
| 1648 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1650 | 0 | return $self->general_action(%$params); | |||||||||||||||||||||||||||||||||||||||||
| 1651 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||||||||||||
| 1653 | 0 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1654 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||||||||||||||||
| 1656 | 0 | ▶ | sub _get_button { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_button: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1657 | 0 | my $button = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1658 | 0 | my $button_enum = { LEFT => 0, MIDDLE => 1, RIGHT => 2 }; | |||||||||||||||||||||||||||||||||||||||||
| 1659 | 0 | ▶ | if ( defined $button && $button =~ /(LEFT|MIDDLE|RIGHT)/i ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $button and $button =~ /(LEFT|MIDDLE|RIGHT)/i
MC/DC0%0/2
defined $button and $button =~ /(LEFT|MIDDLE|RIGHT)/i
defined $button
$button =~ /(LEFT|MIDDLE|RIGHT)/i
Truth table0%0/3
A and B
A= defined $buttonB= $button =~ /(LEFT|MIDDLE|RIGHT)/i
| |||||||||||||||||||||||||||||||||||||||||||
| 1660 | 0 | return $button_enum->{ uc $1 }; | |||||||||||||||||||||||||||||||||||||||||
| 1661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1662 | 0 | ▶ | if ( defined $button && $button =~ /(0|1|2)/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $button and $button =~ /(0|1|2)/
MC/DC0%0/2
defined $button and $button =~ /(0|1|2)/
defined $button
$button =~ /(0|1|2)/
Truth table0%0/3
A and B
A= defined $buttonB= $button =~ /(0|1|2)/
| |||||||||||||||||||||||||||||||||||||||||||
| 1663 | #Handle user error sending in "1" | ||||||||||||||||||||||||||||||||||||||||||
| 1664 | 0 | return int($1); | |||||||||||||||||||||||||||||||||||||||||
| 1665 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1666 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 1667 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||||||||||||||||
| 1670 | 0 | ▶ | sub double_click { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
double_click: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1671 | 0 | my ( $self, $button ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||||||||||||
| 1673 | 0 | $button = _get_button($button); | |||||||||||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||||||||||||
| 1675 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 1676 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 1677 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1678 | 0 | $self->click( $button, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1679 | 0 | $self->click( $button, 1 ); | |||||||||||||||||||||||||||||||||||||||||
| 1680 | 0 | return $self->general_action(); | |||||||||||||||||||||||||||||||||||||||||
| 1681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1682 | |||||||||||||||||||||||||||||||||||||||||||
| 1683 | 0 | my $res = { 'command' => 'doubleClick' }; | |||||||||||||||||||||||||||||||||||||||||
| 1684 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1685 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||||||||||||
| 1687 | |||||||||||||||||||||||||||||||||||||||||||
| 1688 | 0 | ▶ | sub button_down { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
button_down: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1689 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||||||||||||||||
| 1691 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 1692 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 1693 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1694 | 0 | my $params = { | |||||||||||||||||||||||||||||||||||||||||
| 1695 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1696 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1697 | type => "pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 1698 | id => 'mouse', | ||||||||||||||||||||||||||||||||||||||||||
| 1699 | parameters => { "pointerType" => "mouse" }, | ||||||||||||||||||||||||||||||||||||||||||
| 1700 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1701 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1702 | type => "pointerDown", | ||||||||||||||||||||||||||||||||||||||||||
| 1703 | duration => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1704 | button => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1705 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1706 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1707 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1708 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1709 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1710 | 0 | _queue_action(%$params); | |||||||||||||||||||||||||||||||||||||||||
| 1711 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||||||||||||||||
| 1714 | 0 | my $res = { 'command' => 'buttonDown' }; | |||||||||||||||||||||||||||||||||||||||||
| 1715 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||||||||||||||||
| 1719 | 0 | ▶ | sub button_up { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
button_up: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1720 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1721 | |||||||||||||||||||||||||||||||||||||||||||
| 1722 | 0 | ▶ | if ( $self->{is_wd3} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
MC/DC0%0/2
$self->{"is_wd3"} and not grep({$self->browser_name eq $_;} "MicrosoftEdge")
$self->{"is_wd3"}
not grep({$self->browser_name eq $_;} "MicrosoftEdge")
Truth table0%0/3
A and not(B)
A= $self->{"is_wd3"}B= not grep({$self->browser_name eq $_;} "MicrosoftEdge")
| |||||||||||||||||||||||||||||||||||||||||||
| 1723 | 0 | && !( grep { $self->browser_name eq $_ } qw{MicrosoftEdge} ) ) | |||||||||||||||||||||||||||||||||||||||||
| 1724 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1725 | 0 | my $params = { | |||||||||||||||||||||||||||||||||||||||||
| 1726 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1727 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1728 | type => "pointer", | ||||||||||||||||||||||||||||||||||||||||||
| 1729 | id => 'mouse', | ||||||||||||||||||||||||||||||||||||||||||
| 1730 | parameters => { "pointerType" => "mouse" }, | ||||||||||||||||||||||||||||||||||||||||||
| 1731 | actions => [ | ||||||||||||||||||||||||||||||||||||||||||
| 1732 | { | ||||||||||||||||||||||||||||||||||||||||||
| 1733 | type => "pointerUp", | ||||||||||||||||||||||||||||||||||||||||||
| 1734 | duration => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1735 | button => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 1736 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 1737 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1738 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1739 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 1740 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 1741 | 0 | _queue_action(%$params); | |||||||||||||||||||||||||||||||||||||||||
| 1742 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 1743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||||||||||||||||
| 1745 | 0 | my $res = { 'command' => 'buttonUp' }; | |||||||||||||||||||||||||||||||||||||||||
| 1746 | 0 | return $self->_execute_command($res); | |||||||||||||||||||||||||||||||||||||||||
| 1747 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||||||||||||
| 1750 | # this method duplicates upload() method in the | ||||||||||||||||||||||||||||||||||||||||||
| 1751 | # org.openqa.selenium.remote.RemoteWebElement java class. | ||||||||||||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||||||||||||
| 1753 | 5 | ▶ | sub upload_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
upload_file: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1754 | 5 | my ( $self, $filename, $raw_content ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1755 | |||||||||||||||||||||||||||||||||||||||||||
| 1756 | 5 | my $params; | |||||||||||||||||||||||||||||||||||||||||
| 1757 | 5 | ▶ | if ( defined $raw_content ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||||||||||||
| 1759 | #If no processing is passed, send the argument raw | ||||||||||||||||||||||||||||||||||||||||||
| 1760 | 1 | $params = { file => $raw_content }; | |||||||||||||||||||||||||||||||||||||||||
| 1761 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1762 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1763 | #Otherwise, zip/base64 it. | ||||||||||||||||||||||||||||||||||||||||||
| 1764 | 4 | $params = $self->_prepare_file($filename); | |||||||||||||||||||||||||||||||||||||||||
| 1765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1766 | |||||||||||||||||||||||||||||||||||||||||||
| 1767 | 4 | my $res = { 'command' => 'uploadFile' }; # /session/:SessionId/file | |||||||||||||||||||||||||||||||||||||||||
| 1768 | 4 | my $ret = $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1769 | |||||||||||||||||||||||||||||||||||||||||||
| 1770 | 3 | return $ret; | |||||||||||||||||||||||||||||||||||||||||
| 1771 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1772 | |||||||||||||||||||||||||||||||||||||||||||
| 1773 | 4 | ▶ | sub _prepare_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_file: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 1774 | 4 | my ( $self, $filename ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||||||||||||||||
| 1776 | 4 | ▶ | if ( not -r $filename ) { croak "upload_file: no such file: $filename"; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1777 | 3 | my $string = ""; # buffer | |||||||||||||||||||||||||||||||||||||||||
| 1778 | 3 | my $zip = Archive::Zip->new(); | |||||||||||||||||||||||||||||||||||||||||
| 1779 | 3 | $zip->addFile( $filename, basename($filename) ); | |||||||||||||||||||||||||||||||||||||||||
| 1780 | 3 | ▶ | if ( $zip->writeToFileHandle( IO::String->new($string) ) != AZ_OK ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1781 | 0 | die 'zip failed'; | |||||||||||||||||||||||||||||||||||||||||
| 1782 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||||||||||||||||
| 1784 | 3 | return { file => MIME::Base64::encode_base64( $string, '' ) }; | |||||||||||||||||||||||||||||||||||||||||
| 1785 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||||||||||||||||
| 1787 | |||||||||||||||||||||||||||||||||||||||||||
| 1788 | 14 | ▶ | sub get_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_text: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1789 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1790 | 14 | return $self->find_element(@_)->get_text(); | |||||||||||||||||||||||||||||||||||||||||
| 1791 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1792 | |||||||||||||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||||||||||||
| 1794 | 13 | ▶ | sub get_body { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_body: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1795 | 13 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1796 | 13 | return $self->get_text( '//body', 'xpath' ); | |||||||||||||||||||||||||||||||||||||||||
| 1797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1798 | |||||||||||||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||||||||||||
| 1800 | 0 | ▶ | sub get_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_path: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1801 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1802 | 0 | my $location = $self->get_current_url; | |||||||||||||||||||||||||||||||||||||||||
| 1803 | 0 | $location =~ s/\?.*//; # strip of query params | |||||||||||||||||||||||||||||||||||||||||
| 1804 | 0 | $location =~ s/#.*//; # strip of anchors | |||||||||||||||||||||||||||||||||||||||||
| 1805 | 0 | $location =~ s#^https?://[^/]+##; # strip off host | |||||||||||||||||||||||||||||||||||||||||
| 1806 | 0 | return $location; | |||||||||||||||||||||||||||||||||||||||||
| 1807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1808 | |||||||||||||||||||||||||||||||||||||||||||
| 1809 | |||||||||||||||||||||||||||||||||||||||||||
| 1810 | 1 | ▶ | sub get_user_agent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_user_agent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1811 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1812 | 1 | return $self->execute_script('return window.navigator.userAgent;'); | |||||||||||||||||||||||||||||||||||||||||
| 1813 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||||||||||||||||
| 1816 | 0 | ▶ | sub set_inner_window_size { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_inner_window_size: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1817 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1818 | 0 | my $height = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1819 | 0 | my $width = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1820 | 0 | my $location = $self->get_current_url; | |||||||||||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||||||||||||
| 1822 | 0 | $self->execute_script( 'window.open("' . $location . '", "_blank")' ); | |||||||||||||||||||||||||||||||||||||||||
| 1823 | 0 | $self->close; | |||||||||||||||||||||||||||||||||||||||||
| 1824 | 0 | my @handles = @{ $self->get_window_handles }; | |||||||||||||||||||||||||||||||||||||||||
| 1825 | 0 | $self->switch_to_window( pop @handles ); | |||||||||||||||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||||||||||||||||
| 1827 | 0 | my @resize = ( | |||||||||||||||||||||||||||||||||||||||||
| 1828 | 'window.innerHeight = ' . $height, | ||||||||||||||||||||||||||||||||||||||||||
| 1829 | 'window.innerWidth = ' . $width, | ||||||||||||||||||||||||||||||||||||||||||
| 1830 | 'return 1' | ||||||||||||||||||||||||||||||||||||||||||
| 1831 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1832 | |||||||||||||||||||||||||||||||||||||||||||
| 1833 | 0 | ▶ | return $self->execute_script( join( ';', @resize ) ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1834 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||||||||||||||||
| 1836 | |||||||||||||||||||||||||||||||||||||||||||
| 1837 | 2 | ▶ | sub get_local_storage_item { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_local_storage_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1838 | 2 | my ( $self, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1839 | 2 | my $res = { 'command' => 'getLocalStorageItem' }; | |||||||||||||||||||||||||||||||||||||||||
| 1840 | 2 | my $params = { 'key' => $key }; | |||||||||||||||||||||||||||||||||||||||||
| 1841 | 2 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1842 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1843 | |||||||||||||||||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||||||||||||||||
| 1845 | 1 | ▶ | sub delete_local_storage_item { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_local_storage_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1846 | 1 | my ( $self, $key ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1847 | 1 | my $res = { 'command' => 'deleteLocalStorageItem' }; | |||||||||||||||||||||||||||||||||||||||||
| 1848 | 1 | my $params = { 'key' => $key }; | |||||||||||||||||||||||||||||||||||||||||
| 1849 | 1 | return $self->_execute_command( $res, $params ); | |||||||||||||||||||||||||||||||||||||||||
| 1850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||||||||||||
| 1852 | 7 | ▶ | sub _coerce_timeout_ms { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_timeout_ms: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1853 | 7 | my ($ms) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1854 | |||||||||||||||||||||||||||||||||||||||||||
| 1855 | 7 | ▶ | if ( defined $ms ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1856 | 6 | return _coerce_number($ms); | |||||||||||||||||||||||||||||||||||||||||
| 1857 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1858 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1859 | 1 | croak 'Expecting a timeout in ms'; | |||||||||||||||||||||||||||||||||||||||||
| 1860 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1861 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||||||||||||||||
| 1863 | 7 | ▶ | sub _coerce_number { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_coerce_number: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 1864 | 7 | my ($maybe_number) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1865 | |||||||||||||||||||||||||||||||||||||||||||
| 1866 | 7 | ▶ | if ( Scalar::Util::looks_like_number($maybe_number) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1867 | 2 | return $maybe_number + 0; | |||||||||||||||||||||||||||||||||||||||||
| 1868 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1869 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1870 | 5 | croak "Expecting a number, not: $maybe_number"; | |||||||||||||||||||||||||||||||||||||||||
| 1871 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1872 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1873 | |||||||||||||||||||||||||||||||||||||||||||
| 1874 | 26 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||||||||||||
| 1876 | __END__ | ||||||||||||||||||||||||||||||||||||||||||