| 1 | package WWW::Mechanize::Chrome::Node; | ||||||||||||||||||||||||||||
| 2 | 69 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 69 | ▶ | use 5.020; # __SUB__, signatures | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 69 | ▶ | use Moo 2; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 69 | ▶ | no warnings 'experimental::signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 69 | ▶ | use feature 'signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 69 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 69 | ▶ | use JSON; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 69 | ▶ | use Scalar::Util 'weaken'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | WWW::Mechanize::Chrome::Node - represent a Chrome HTML node in Perl | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | (my $node) = $mech->selector('.download'); | ||||||||||||||||||||||||||||
| 19 | print $node->get_attribute('class'); # "download" | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =cut | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 69 | our $VERSION = '0.80'; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 MEMBERS | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | =head2 C<attributes> | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | The attributes this node has | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | has 'attributes' => ( | ||||||||||||||||||||||||||||
| 34 | is => 'lazy', | ||||||||||||||||||||||||||||
| 35 | 0 | ▶ | default => sub { {} }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 36 | 69 | ); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head2 C<nodeName> | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | The (tag) name of this node, with a namespace | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 69 | has 'nodeName' => ( | |||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head2 C<nodeId> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | The nodeId of this node | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 69 | has 'nodeId' => ( | |||||||||||||||||||||||||||
| 55 | is => 'ro', | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | =head2 C<localName> | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | The local (tag) name of this node | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =cut | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 69 | has 'localName' => ( | |||||||||||||||||||||||||||
| 64 | is => 'ro', | ||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head2 C<backendNodeId> | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | The id of this node within Chrome | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 69 | has 'backendNodeId' => ( | |||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 C<cachedNodeId> | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | The cached id of this node for this session | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =cut | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 69 | has 'cachedNodeId' => ( | |||||||||||||||||||||||||||
| 84 | is => 'rw', | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =head2 C<objectId> | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | Another id of this node within Chrome | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | has 'objectId' => ( | ||||||||||||||||||||||||||||
| 94 | is => 'lazy', | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | default => sub { $_[0]->_fetchObjectId()->get }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 96 | 69 | ); | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head2 C<driver> | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | The L<Chrome::DevToolsProtocol::Transport> instance used to communicate | ||||||||||||||||||||||||||||
| 101 | with Chrome | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 69 | has 'driver' => ( | |||||||||||||||||||||||||||
| 106 | is => 'ro', | ||||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | # The generation from when our ->nodeId was valid | ||||||||||||||||||||||||||||
| 110 | 69 | has '_generation' => ( | |||||||||||||||||||||||||||
| 111 | is => 'rw', | ||||||||||||||||||||||||||||
| 112 | ); | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head2 C<mech> | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | A weak reference to the L<WWW::Mechanize::Chrome> instance used to communicate | ||||||||||||||||||||||||||||
| 117 | with Chrome. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 69 | has 'mech' => ( | |||||||||||||||||||||||||||
| 122 | is => 'ro', | ||||||||||||||||||||||||||||
| 123 | weak_ref => 1, | ||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head1 CONSTRUCTORS | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head2 C<< fetchNode >> | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | WWW::Mechanize::Chrome->fetchNode( | ||||||||||||||||||||||||||||
| 132 | nodeId => $nodeId, | ||||||||||||||||||||||||||||
| 133 | driver => $mech->driver, | ||||||||||||||||||||||||||||
| 134 | )->get() | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | Returns a L<Future> that returns a populated node. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub fetchNode( $class, %options ) { | ||||||||||||||||||||||||||
|
Subroutine
fetchNode: not called CC=5 SCAR=32.5
Pod
documented
| |||||||||||||||||||||||||||||
| 141 | my $driver = delete $options{ driver } | ||||||||||||||||||||||||||||
| 142 | 0 | ▶ | or croak "Need a valid driver for communication"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | weaken $driver; | |||||||||||||||||||||||||||
| 144 | defined(my $nodeId = delete $options{ nodeId }) | ||||||||||||||||||||||||||||
| 145 | 0 | ▶ | or croak "Need a valid nodeId for requesting"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 0 | my $body = delete $options{ body }; | |||||||||||||||||||||||||||
| 147 | 0 | my $attributes = delete $options{ attributes }; | |||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if( $body ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 150 | 0 | $body = Future->done( $body ); | |||||||||||||||||||||||||||
| 151 | } else { | ||||||||||||||||||||||||||||
| 152 | 0 | my %info; | |||||||||||||||||||||||||||
| 153 | $body = $driver->send_message( 'DOM.resolveNode', nodeId => 0+$nodeId ) | ||||||||||||||||||||||||||||
| 154 | 0 | ▶ | ->then( sub( $info ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 155 | 0 | %info = %{$info->{object}}; | |||||||||||||||||||||||||||
| 156 | $driver->send_message( 'DOM.requestNode', objectId => $info{objectId} ) | ||||||||||||||||||||||||||||
| 157 | 0 | ▶ | })->then(sub( $info ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 158 | 0 | %info = (%info, %$info); | |||||||||||||||||||||||||||
| 159 | $driver->send_message( 'DOM.describeNode', objectId => $info{objectId} ) | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | })->then(sub( $info ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 161 | 0 | %info = (%info, %{$info->{node}}, nodeId => 0+$nodeId); | |||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | Future->done( \%info ); | |||||||||||||||||||||||||||
| 164 | 0 | ▶ | })->catch( sub(@error) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||
| 165 | 0 | warn "Couldn't resolve node $nodeId!"; | |||||||||||||||||||||||||||
| 166 | 0 | ▶ | use Data::Dumper; warn Dumper \@error; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 167 | }) | ||||||||||||||||||||||||||||
| 168 | 0 | }; | |||||||||||||||||||||||||||
| 169 | 0 | ▶ | if( $attributes ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | 0 | $attributes = Future->done( $attributes ) | |||||||||||||||||||||||||||
| 171 | } else { | ||||||||||||||||||||||||||||
| 172 | 0 | $attributes = $driver->send_message( 'DOM.getAttributes', nodeId => 0+$nodeId ); | |||||||||||||||||||||||||||
| 173 | }; | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return Future->wait_all( $body, $attributes )->then( sub( $body, $attributes ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 176 | 0 | $body = $body->get; | |||||||||||||||||||||||||||
| 177 | 0 | my $attr = $attributes->get; | |||||||||||||||||||||||||||
| 178 | 0 | $attributes = $attr->{attributes}; | |||||||||||||||||||||||||||
| 179 | 0 | my $nodeName = $body->{description}; | |||||||||||||||||||||||||||
| 180 | 0 | $nodeName =~ s!#.*!!; | |||||||||||||||||||||||||||
| 181 | #warn "Backend for $nodeId is $attr->{ backendNodeId }"; | ||||||||||||||||||||||||||||
| 182 | #use Data::Dumper; | ||||||||||||||||||||||||||||
| 183 | #warn Dumper $attr; | ||||||||||||||||||||||||||||
| 184 | #warn Dumper $body; | ||||||||||||||||||||||||||||
| 185 | #die unless $attr->{backendNodeId}; | ||||||||||||||||||||||||||||
| 186 | my $node = { | ||||||||||||||||||||||||||||
| 187 | cachedNodeId => $nodeId, | ||||||||||||||||||||||||||||
| 188 | objectId => $body->{ objectId }, | ||||||||||||||||||||||||||||
| 189 | backendNodeId => $body->{backendNodeId} || $attr->{ backendNodeId }, | ||||||||||||||||||||||||||||
| 190 | nodeId => $nodeId, | ||||||||||||||||||||||||||||
| 191 | parentId => $body->{ parentId }, | ||||||||||||||||||||||||||||
| 192 | attributes => { | ||||||||||||||||||||||||||||
| 193 | 0 | ▶ | @{ $attributes }, | ||||||||||||||||||||||||||
|
Condition0%0/3
$body->{'backendNodeId'} || $attr->{'backendNodeId'}
MC/DC0%0/2
$body->{'backendNodeId'} || $attr->{'backendNodeId'}
$body->{'backendNodeId'}
$attr->{'backendNodeId'}
Truth table0%0/3
A || B
A= $body->{'backendNodeId'}B= $attr->{'backendNodeId'}
| |||||||||||||||||||||||||||||
| 194 | }, | ||||||||||||||||||||||||||||
| 195 | nodeName => $nodeName, | ||||||||||||||||||||||||||||
| 196 | #driver => $driver, | ||||||||||||||||||||||||||||
| 197 | #mech => $s, | ||||||||||||||||||||||||||||
| 198 | #_generation => $s->_generation, | ||||||||||||||||||||||||||||
| 199 | }; | ||||||||||||||||||||||||||||
| 200 | 0 | $node->{driver} = $driver; | |||||||||||||||||||||||||||
| 201 | 0 | my $n = $class->new( $node ); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | # Fetch additional data into the object | ||||||||||||||||||||||||||||
| 204 | #return $n->_nodeId()->then(sub { | ||||||||||||||||||||||||||||
| 205 | # unless( $n->backendNodeId ) { | ||||||||||||||||||||||||||||
| 206 | # warn Dumper [ $body, $attributes ]; | ||||||||||||||||||||||||||||
| 207 | # die; | ||||||||||||||||||||||||||||
| 208 | # }; | ||||||||||||||||||||||||||||
| 209 | #}); | ||||||||||||||||||||||||||||
| 210 | 0 | Future->done( $n ); | |||||||||||||||||||||||||||
| 211 | 0 | ▶ | })->catch(sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 212 | 0 | warn "@_"; | |||||||||||||||||||||||||||
| 213 | 0 | warn "Node $nodeId has gone away in the meantime, could not resolve"; | |||||||||||||||||||||||||||
| 214 | 0 | Future->done( $class->new( {} ) ); | |||||||||||||||||||||||||||
| 215 | 0 | }); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub _fetchObjectId( $self ) { | ||||||||||||||||||||||||||
|
Subroutine
_fetchObjectId: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 219 | #warn "Realizing objectId"; | ||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if( $self->{objectId}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | return Future->done( $self->{objectId} ) | ||||||||||||||||||||||||||||
| 222 | 0 | } else { | |||||||||||||||||||||||||||
| 223 | 0 | weaken(my $s=$self); | |||||||||||||||||||||||||||
| 224 | 0 | my $nodeId = 0+$s->nodeId; | |||||||||||||||||||||||||||
| 225 | $s->{_fetchObjectId} = | ||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $self->driver->send_message('DOM.resolveNode', nodeId => $nodeId)->then(sub( $obj ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 227 | 0 | $s->{objectId} = $obj->{object}->{objectId}; | |||||||||||||||||||||||||||
| 228 | 0 | Future->done( $obj->{object}->{objectId} ); | |||||||||||||||||||||||||||
| 229 | 0 | ▶ | })->catch(sub(@error) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 230 | # ignore this error here and silence it | ||||||||||||||||||||||||||||
| 231 | 0 | $s->{_fetchObjectId}->cancel; | |||||||||||||||||||||||||||
| 232 | 0 | delete $s->{_fetchObjectId}; | |||||||||||||||||||||||||||
| 233 | 0 | }); | |||||||||||||||||||||||||||
| 234 | #); | ||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub _fetchNodeId($self) { | ||||||||||||||||||||||||||
|
Subroutine
_fetchNodeId: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 239 | 0 | weaken( my $s = $self ); | |||||||||||||||||||||||||||
| 240 | 0 | ▶ | $self->_fetchObjectId->then(sub( $objectId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 241 | 0 | $self->driver->send_message('DOM.requestNode', objectId => $objectId) | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | })->then(sub($d) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if( ! exists $d->{node} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | # Ugh - that node has gone away before we could request it ... | ||||||||||||||||||||||||||||
| 245 | 0 | Future->done( $d->{nodeId} ); | |||||||||||||||||||||||||||
| 246 | } else { | ||||||||||||||||||||||||||||
| 247 | 0 | $s->{backendNodeId} = 0+$d->{node}->{backendNodeId}; | |||||||||||||||||||||||||||
| 248 | 0 | ▶ | $s->{nodeId} = 0+$d->{node}->{nodeId} // 0+$s->{nodeId}; # keep old one ... | ||||||||||||||||||||||||||
|
Condition0%0/2
0 + $d->{"node"}{"nodeId"} // 0 + $s->{"nodeId"}
MC/DC0%0/1
0 + $d->{"node"}{"nodeId"} // 0 + $s->{"nodeId"}
0 + $d->{"node"}{"nodeId"}
Truth table0%0/2
A
A= 0 + $d->{"node"}{"nodeId"}
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $s->cachedNodeId( 0+$d->{node}->{nodeId} // 0+$s->{nodeId} ); | ||||||||||||||||||||||||||
|
Condition0%0/2
0 + $d->{"node"}{"nodeId"} // 0 + $s->{"nodeId"}
MC/DC0%0/1
0 + $d->{"node"}{"nodeId"} // 0 + $s->{"nodeId"}
0 + $d->{"node"}{"nodeId"}
Truth table0%0/2
A
A= 0 + $d->{"node"}{"nodeId"}
| |||||||||||||||||||||||||||||
| 250 | 0 | Future->done( $s->{nodeId} ); | |||||||||||||||||||||||||||
| 251 | }; | ||||||||||||||||||||||||||||
| 252 | 0 | }); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub _nodeId($self) { | ||||||||||||||||||||||||||
|
Subroutine
_nodeId: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 256 | 0 | my $nid; | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | if( my $mech = $self->mech ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | my $generation = $mech->_generation; | |||||||||||||||||||||||||||
| 259 | 0 | ▶ | if( !$self->_generation or $self->_generation != $generation ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $self->_generation or $self->_generation != $generation
MC/DC0%0/2
not $self->_generation or $self->_generation != $generation
not $self->_generation
$self->_generation != $generation
Truth table0%0/3
not(A) or B
A= not $self->_generationB= $self->_generation != $generation
| |||||||||||||||||||||||||||||
| 260 | # Re-resolve, and hopefully we still have our objectId | ||||||||||||||||||||||||||||
| 261 | 0 | $nid = $self->_fetchNodeId(); | |||||||||||||||||||||||||||
| 262 | 0 | $self->_generation( $generation ); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | else { | ||||||||||||||||||||||||||||
| 266 | 0 | $nid = Future->done( 0+$self->cachedNodeId ); | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | 0 | $nid; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | # | ||||||||||||||||||||||||||||
| 271 | #=head2 C<< ->nodeId >> | ||||||||||||||||||||||||||||
| 272 | # | ||||||||||||||||||||||||||||
| 273 | # print $node->nodeId(); | ||||||||||||||||||||||||||||
| 274 | # | ||||||||||||||||||||||||||||
| 275 | #Lazily fetches the node id of this node. Use C<< ->_nodeId >> for a version | ||||||||||||||||||||||||||||
| 276 | #that returns a Future. | ||||||||||||||||||||||||||||
| 277 | # | ||||||||||||||||||||||||||||
| 278 | #=cut | ||||||||||||||||||||||||||||
| 279 | # | ||||||||||||||||||||||||||||
| 280 | #sub nodeId($self) { | ||||||||||||||||||||||||||||
| 281 | # $self->_nodeId()->get; | ||||||||||||||||||||||||||||
| 282 | #} | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | =head1 METHODS | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | =cut | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =head2 C<< ->get_attribute >> | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | print $node->get_attribute('outerHTML'); | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | Fetches the attribute of the node from Chrome | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | print $node->get_attribute('href', live => 1); | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | Force a live query of the attribute to Chrome. If the attribute was declared | ||||||||||||||||||||||||||||
| 297 | on the node, this overrides the stored value and queries Chrome again for | ||||||||||||||||||||||||||||
| 298 | the current value of the attribute. | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | =cut | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub _false_to_undef( $val ) { | ||||||||||||||||||||||||||
|
Subroutine
_false_to_undef: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if( ref $val and ref $val eq 'JSON::PP::Boolean' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $val and ref $val eq "JSON::PP::Boolean"
MC/DC0%0/2
ref $val and ref $val eq "JSON::PP::Boolean"
ref $val
ref $val eq "JSON::PP::Boolean"
Truth table0%0/3
A and B
A= ref $valB= ref $val eq "JSON::PP::Boolean"
| |||||||||||||||||||||||||||||
| 304 | 0 | ▶ | $val = $val ? $val : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 0 | return $val | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | sub _fetch_attribute_eval( $self, $attribute ) { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_attribute_eval: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 310 | 0 | weaken(my $s=$self); | |||||||||||||||||||||||||||
| 311 | $self->_fetchObjectId | ||||||||||||||||||||||||||||
| 312 | 0 | ▶ | ->then( sub( $objectId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 313 | 0 | $s->driver->send_message('Runtime.callFunctionOn', | |||||||||||||||||||||||||||
| 314 | functionDeclaration => '(o,a) => { console.log(o[a]); return o[a] }', | ||||||||||||||||||||||||||||
| 315 | arguments => [ { objectId => $objectId }, { value => $attribute } ], | ||||||||||||||||||||||||||||
| 316 | objectId => $objectId, | ||||||||||||||||||||||||||||
| 317 | returnByValue => JSON::true | ||||||||||||||||||||||||||||
| 318 | ) | ||||||||||||||||||||||||||||
| 319 | }) | ||||||||||||||||||||||||||||
| 320 | 0 | ▶ | ->then(sub($res) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 321 | 0 | $res = $res->{result}->{value}; | |||||||||||||||||||||||||||
| 322 | 0 | return Future->done( _false_to_undef( $res )) | |||||||||||||||||||||||||||
| 323 | 0 | }); | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub _fetch_attribute_attribute( $self, $attribute ) { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_attribute_attribute: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 327 | $self->driver->send_message('DOM.getAttributes', | ||||||||||||||||||||||||||||
| 328 | nodeId => 0+$self->nodeId, | ||||||||||||||||||||||||||||
| 329 | ) | ||||||||||||||||||||||||||||
| 330 | 0 | ▶ | ->then(sub($_res) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 331 | 0 | my %attr = @{ $_res->{attributes} }; | |||||||||||||||||||||||||||
| 332 | 0 | my $res = $attr{ $attribute }; | |||||||||||||||||||||||||||
| 333 | 0 | return Future->done( _false_to_undef( $res )) | |||||||||||||||||||||||||||
| 334 | 0 | }); | |||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | ▶ | sub _fetch_attribute_property( $self, $attribute ) { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_attribute_property: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 338 | $self->_fetchObjectId | ||||||||||||||||||||||||||||
| 339 | 0 | ▶ | ->then( sub( $objectId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 340 | 0 | $self->driver->send_message('Runtime.getProperties', | |||||||||||||||||||||||||||
| 341 | objectId => $objectId, | ||||||||||||||||||||||||||||
| 342 | #ownProperties => JSON::true, | ||||||||||||||||||||||||||||
| 343 | #accessorPropertiesOnly => JSON::true, | ||||||||||||||||||||||||||||
| 344 | #returnByValue => JSON::true | ||||||||||||||||||||||||||||
| 345 | )}) | ||||||||||||||||||||||||||||
| 346 | 0 | ▶ | ->then(sub($_res) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 347 | 0 | (my $attr) = grep { $_->{name} eq $attribute } @{ $_res->{result} }; | |||||||||||||||||||||||||||
| 348 | 0 | ▶ | $attr //= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$attr //= {}
MC/DC0%0/1
$attr //= {}
$attr
Truth table0%0/2
A
A= $attr
| |||||||||||||||||||||||||||||
| 349 | 0 | my $res = $attr->{value}->{value}; | |||||||||||||||||||||||||||
| 350 | 0 | return Future->done( _false_to_undef( $res )) | |||||||||||||||||||||||||||
| 351 | 0 | }); | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | ▶ | sub _fetch_attribute( $self, $attribute ) { | ||||||||||||||||||||||||||
|
Subroutine
_fetch_attribute: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 355 | 0 | weaken(my $s=$self); | |||||||||||||||||||||||||||
| 356 | 0 | ▶ | my $attr = $s->_fetch_attribute_attribute( $attribute )->then(sub ($val) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if( ! defined $val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 0 | ▶ | my $attr = $s->_fetch_attribute_property( $attribute )->then(sub ($val) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 359 | 0 | ▶ | if( ! defined $val) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 360 | 0 | return $s->_fetch_attribute_eval( $attribute ) | |||||||||||||||||||||||||||
| 361 | } else { | ||||||||||||||||||||||||||||
| 362 | 0 | return Future->done( $val ) | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | }) | ||||||||||||||||||||||||||||
| 365 | 0 | } else { | |||||||||||||||||||||||||||
| 366 | 0 | return Future->done( $val ) | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | 0 | }); | |||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub get_attribute_future( $self, $attribute, %options ) { | ||||||||||||||||||||||||||
|
Subroutine
get_attribute_future: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 372 | 0 | my $s = $self; | |||||||||||||||||||||||||||
| 373 | 0 | weaken $s; | |||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if( $attribute eq 'innerHTML' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 376 | my $html = $s->get_attribute_future('outerHTML') | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | ->then(sub( $html ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 378 | # Strip first and last tag in a not so elegant way | ||||||||||||||||||||||||||||
| 379 | 0 | $html =~ s!\A<[^>]+>!!; | |||||||||||||||||||||||||||
| 380 | 0 | $html =~ s!<[^>]+>\z!!; | |||||||||||||||||||||||||||
| 381 | 0 | Future->done( $html ) | |||||||||||||||||||||||||||
| 382 | 0 | }); | |||||||||||||||||||||||||||
| 383 | 0 | return $html | |||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | } elsif( $attribute eq 'outerHTML' ) { | ||||||||||||||||||||||||||||
| 386 | 0 | my $nid = $s->_fetchNodeId(); | |||||||||||||||||||||||||||
| 387 | # If we only have a backendNodeId, use that | ||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $html = $nid->then(sub( $nodeId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 389 | 0 | (my $key) = grep { $s->$_ } (qw(backendNodeId nodeId)); | |||||||||||||||||||||||||||
| 390 | 0 | my $val; | |||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if( ! $key ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 393 | 0 | $key = 'nodeId'; | |||||||||||||||||||||||||||
| 394 | 0 | $val = 0+$nodeId; | |||||||||||||||||||||||||||
| 395 | } else { | ||||||||||||||||||||||||||||
| 396 | 0 | $val = $self->$key; | |||||||||||||||||||||||||||
| 397 | }; | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | #$s->driver->send_message('DOM.getOuterHTML', nodeId => 0+$nodeId ) | ||||||||||||||||||||||||||||
| 400 | 0 | $s->driver->send_message('DOM.getOuterHTML', $key => $val ) | |||||||||||||||||||||||||||
| 401 | 0 | ▶ | })->then(sub( $res ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 402 | Future->done( $res->{outerHTML} ) | ||||||||||||||||||||||||||||
| 403 | 0 | }); | |||||||||||||||||||||||||||
| 404 | 0 | return $html | |||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | } else { | ||||||||||||||||||||||||||||
| 407 | #warn "Fetching '$attribute'"; | ||||||||||||||||||||||||||||
| 408 | 0 | return $self->_fetch_attribute($attribute); | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub get_attribute( $self, $attribute, %options ) { | ||||||||||||||||||||||||||
|
Subroutine
get_attribute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 413 | 0 | $self->get_attribute_future( $attribute, %options )->get() | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | =head2 C<< ->set_attribute >> | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | $node->set_attribute('href' => 'https://example.com'); | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | Sets or creates an attribute of a node. To remove an attribute, | ||||||||||||||||||||||||||||
| 421 | pass in the attribute value as C<undef>. | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | Note that this invalidates the C<nodeId> of every node so you may or may not | ||||||||||||||||||||||||||||
| 424 | need to refetch all other nodes or receive stale values. | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | =cut | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 0 | ▶ | sub set_attribute_future( $self, $attribute, $value ) { | ||||||||||||||||||||||||||
|
Subroutine
set_attribute_future: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 429 | 0 | my $s = $self; | |||||||||||||||||||||||||||
| 430 | 0 | weaken $s; | |||||||||||||||||||||||||||
| 431 | 0 | my $r; | |||||||||||||||||||||||||||
| 432 | 0 | ▶ | if( defined $value ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | $r = $self->_fetchNodeId() | ||||||||||||||||||||||||||||
| 434 | 0 | ▶ | ->then(sub( $nodeId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 435 | 0 | $s->driver->send_message( | |||||||||||||||||||||||||||
| 436 | 'DOM.setAttributeValue', | ||||||||||||||||||||||||||||
| 437 | name => $attribute, | ||||||||||||||||||||||||||||
| 438 | value => ''.$value, | ||||||||||||||||||||||||||||
| 439 | nodeId => 0+$nodeId | ||||||||||||||||||||||||||||
| 440 | ) | ||||||||||||||||||||||||||||
| 441 | }) | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 0 | } else { | |||||||||||||||||||||||||||
| 444 | $r = $self->_fetchNodeId() | ||||||||||||||||||||||||||||
| 445 | 0 | ▶ | ->then(sub( $nodeId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 446 | 0 | $s->driver->send_message('DOM.removeAttribute', | |||||||||||||||||||||||||||
| 447 | name => $attribute, | ||||||||||||||||||||||||||||
| 448 | nodeId => 0+$nodeId | ||||||||||||||||||||||||||||
| 449 | ) | ||||||||||||||||||||||||||||
| 450 | }) | ||||||||||||||||||||||||||||
| 451 | 0 | } | |||||||||||||||||||||||||||
| 452 | 0 | return $r | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 0 | ▶ | sub set_attribute( $self, $attribute, $value ) { | ||||||||||||||||||||||||||
|
Subroutine
set_attribute: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 456 | 0 | $self->set_attribute_future( $attribute, $value )->get | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =head2 C<< ->get_tag_name >> | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | print $node->get_tag_name(); | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Fetches the tag name of this node | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | =cut | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | sub get_tag_name( $self ) { | ||||||||||||||||||||||||||
|
Subroutine
get_tag_name: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | my $tag = $self->nodeName // ""; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->nodeName // ""
MC/DC0%0/1
$self->nodeName // ""
$self->nodeName
Truth table0%0/2
A
A= $self->nodeName
| |||||||||||||||||||||||||||||
| 469 | 0 | $tag =~ s!\..*!!; # strip away the eventual classname | |||||||||||||||||||||||||||
| 470 | 0 | $tag | |||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | =head2 C<< ->get_text >> | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | print $node->get_text(); | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | Returns the text of the node and the contained child nodes. | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | 0 | ▶ | sub get_text( $self ) { | ||||||||||||||||||||||||||
|
Subroutine
get_text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 482 | # We need to describe all the children and concatenate their | ||||||||||||||||||||||||||||
| 483 | # contents to retrieve the text... | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | #$self->driver->send_message('DOM.describeNode', | ||||||||||||||||||||||||||||
| 486 | # nodeId => 0+$self->nodeId, depth => -1)->then(sub($info) { | ||||||||||||||||||||||||||||
| 487 | # | ||||||||||||||||||||||||||||
| 488 | # my $text = ''; | ||||||||||||||||||||||||||||
| 489 | # | ||||||||||||||||||||||||||||
| 490 | # my $collect_text = sub( $n ) { | ||||||||||||||||||||||||||||
| 491 | # if( $n->{nodeType} == 3 ) { | ||||||||||||||||||||||||||||
| 492 | # $text .= $n->{nodeValue} // ''; | ||||||||||||||||||||||||||||
| 493 | # }; | ||||||||||||||||||||||||||||
| 494 | # for( $n->{children}->@* ) { | ||||||||||||||||||||||||||||
| 495 | # __SUB__->($_); | ||||||||||||||||||||||||||||
| 496 | # } | ||||||||||||||||||||||||||||
| 497 | # }; | ||||||||||||||||||||||||||||
| 498 | # $collect_text->( $info->{node} ); | ||||||||||||||||||||||||||||
| 499 | # | ||||||||||||||||||||||||||||
| 500 | # Future->done( $text ) | ||||||||||||||||||||||||||||
| 501 | #})->get; | ||||||||||||||||||||||||||||
| 502 | 0 | $self->get_attribute('innerText') | |||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | =head2 C<< ->set_text >> | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | $node->set_text("Hello World"); | ||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||
| 509 | Sets the text of the node and the contained child nodes. | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | =cut | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub set_text_future( $self, $value ) { | ||||||||||||||||||||||||||
|
Subroutine
set_text_future: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 514 | 0 | my $s = $self; | |||||||||||||||||||||||||||
| 515 | 0 | weaken $s; | |||||||||||||||||||||||||||
| 516 | 0 | my $nid = $self->_nodeId(); | |||||||||||||||||||||||||||
| 517 | 0 | ▶ | $nid->then(sub( $nodeId ) { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 518 | 0 | $s->driver->send_message('DOM.setNodeValue', nodeId => 0+$nodeId, value => $value ) | |||||||||||||||||||||||||||
| 519 | 0 | }); | |||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 0 | ▶ | sub set_text( $self, $value ) { | ||||||||||||||||||||||||||
|
Subroutine
set_text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 523 | 0 | $self->set_text_future->get() | |||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 69 | 1; | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | =head1 REPOSITORY | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | The public repository of this module is | ||||||||||||||||||||||||||||
| 531 | L<https://github.com/Corion/www-mechanize-chrome>. | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | The public support forum of this module is L<https://perlmonks.org/>. | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | =head1 TALKS | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | I've given a German talk at GPW 2017, see L<http://act.yapc.eu/gpw2017/talk/7027> | ||||||||||||||||||||||||||||
| 540 | and L<https://corion.net/talks> for the slides. | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | At The Perl Conference 2017 in Amsterdam, I also presented a talk, see | ||||||||||||||||||||||||||||
| 543 | L<http://act.perlconference.org/tpc-2017-amsterdam/talk/7022>. | ||||||||||||||||||||||||||||
| 544 | The slides for the English presentation at TPCiA 2017 are at | ||||||||||||||||||||||||||||
| 545 | L<https://corion.net/talks/WWW-Mechanize-Chrome/www-mechanize-chrome.en.html>. | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | =head1 BUG TRACKER | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | Please report bugs in this module via the Github bug queue at | ||||||||||||||||||||||||||||
| 550 | L<https://github.com/Corion/WWW-Mechanize-Chrome/issues> | ||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||
| 552 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | Max Maischein C<corion@cpan.org> | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | =head1 COPYRIGHT (c) | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | Copyright 2010-2026 by Max Maischein C<corion@cpan.org>. | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | This module is released under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | =cut | ||||||||||||||||||||||||||||