use strict; use warnings; use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; my $mech = WWW::Mechanize::Chrome->new; $mech->get('https://metacpan.org/'); sleep(1); my @nodes = $mech->xpath('//p'); $mech->highlight_node($mech,@nodes); sleep(3); #### highlight_nodes(@nodes); sub highlight_nodes { my @nodes = @_; foreach my $node (@nodes) { my $objectId = $$node{objectId}; $mech->callFunctionOn( 'function() { if( "none" == this.style.display ) { this.style.display= "block"; }; this.style.backgroundColor = "red"; this.style.border = "solid black 1px" }', objectId => $objectId, arguments => [] ); } }