Skip Menu |

This queue is for tickets about the WWW-Mechanize-Chrome CPAN distribution.

Report information
The Basics
Id: 131000
Status: resolved
Priority: 0/
Queue: WWW-Mechanize-Chrome

People
Owner: Nobody in particular
Requestors: Chris.Denley [...] experian.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.40



Date: Thu, 14 Nov 2019 23:15:17 +0000
Subject: get_text and get_attribute('innerText') return html
To: "bug-WWW-Mechanize-Chrome [...] rt.cpan.org" <bug-WWW-Mechanize-Chrome [...] rt.cpan.org>
From: "Denley, Chris" <Chris.Denley [...] experian.com>
use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; use Data::Dumper; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $mech = WWW::Mechanize::Chrome->new(); $mech->get('https://metacpan.org/pod/WWW::Mechanize::Chrome::Node'); my $node = $mech->xpath('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a',single=>1); print $node->get_text()."\n"; print $node->get_attribute('innerText')."\n"; my ($val,$type) = $mech->eval("document.evaluate('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"); print "What I expect: $val\n"; <span itemprop="name">Max Maischein</span> <span itemprop="name">Max Maischein</span> What I expect: Max Maischein
Date: Fri, 15 Nov 2019 16:16:50 +0000
Subject: RE: [rt.cpan.org #131000] AutoReply: get_text and get_attribute('innerText') return html
To: "bug-WWW-Mechanize-Chrome [...] rt.cpan.org" <bug-WWW-Mechanize-Chrome [...] rt.cpan.org>
From: "Denley, Chris" <Chris.Denley [...] experian.com>
I think I found a much cleaner workaround which may be of use to you, which queries the runtime property through Chrome::DevToolsProtocol. use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $mech = WWW::Mechanize::Chrome->new(); $mech->get('https://metacpan.org/pod/WWW::Mechanize::Chrome::Node'); my $node = $mech->xpath('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a',single=>1); print $node->get_text()."\n"; print $node->get_attribute('innerText')."\n"; my $ret = $mech->target->send_message('Runtime.getProperties',objectId=>$node->{'objectId'},ownProperties=>JSON::false)->get()->{'result'}; my %props = map {$$_{'name'} => $$_{'value'}{'value'}} @$ret; print $props{'innerText'}."\n"; Show quoted text
-----Original Message----- From: Bugs in WWW-Mechanize-Chrome via RT <bug-WWW-Mechanize-Chrome@rt.cpan.org> Sent: Thursday, November 14, 2019 5:16 PM To: Denley, Chris <Chris.Denley@experian.com> Subject: [rt.cpan.org #131000] AutoReply: get_text and get_attribute('innerText') return html Greetings, This message has been automatically generated in response to the creation of a trouble ticket regarding: "get_text and get_attribute('innerText') return html", a summary of which appears below. There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #131000]. Your ticket is accessible on the web at: https://rt.cpan.org/Ticket/Display.html?id=131000 Please include the string: [rt.cpan.org #131000] in the subject line of all future correspondence about this issue. To do so, you may reply to this message. Thank you, bug-WWW-Mechanize-Chrome@rt.cpan.org ------------------------------------------------------------------------- use Log::Log4perl qw(:easy); use WWW::Mechanize::Chrome; use Data::Dumper; Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $mech = WWW::Mechanize::Chrome->new(); $mech->get('https://metacpan.org/pod/WWW::Mechanize::Chrome::Node'); my $node = $mech->xpath('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a',single=>1); print $node->get_text()."\n"; print $node->get_attribute('innerText')."\n"; my ($val,$type) = $mech->eval("document.evaluate('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"); print "What I expect: $val\n"; <span itemprop="name">Max Maischein</span> <span itemprop="name">Max Maischein</span> What I expect: Max Maischein
Subject: Re: [rt.cpan.org #131000] AutoReply: get_text and get_attribute('innerText') return html
Date: Fri, 15 Nov 2019 17:18:17 +0100
To: bug-WWW-Mechanize-Chrome [...] rt.cpan.org
From: Max Maischein <corion [...] corion.net>
Hello Chris, Oh, that looks interesting! I already have a different workaround, but your workaround looks much cleaner! I expect to release a new version with one of the two fixes in the next 24 hours! Thanks for reporting and even fixing this, -max On 15.11.19 17:17, Denley, Chris via RT wrote: Show quoted text
> Queue: WWW-Mechanize-Chrome > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=131000 > > > I think I found a much cleaner workaround which may be of use to you, which queries the runtime property through Chrome::DevToolsProtocol. > > use Log::Log4perl qw(:easy); > use WWW::Mechanize::Chrome; > > Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR > my $mech = WWW::Mechanize::Chrome->new(); > $mech->get('https://metacpan.org/pod/WWW::Mechanize::Chrome::Node'); > my $node = $mech->xpath('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a',single=>1); > print $node->get_text()."\n"; > print $node->get_attribute('innerText')."\n"; > my $ret = $mech->target->send_message('Runtime.getProperties',objectId=>$node->{'objectId'},ownProperties=>JSON::false)->get()->{'result'}; > my %props = map {$$_{'name'} => $$_{'value'}{'value'}} @$ret; > print $props{'innerText'}."\n"; > > -----Original Message----- > From: Bugs in WWW-Mechanize-Chrome via RT <bug-WWW-Mechanize-Chrome@rt.cpan.org> > Sent: Thursday, November 14, 2019 5:16 PM > To: Denley, Chris <Chris.Denley@experian.com> > Subject: [rt.cpan.org #131000] AutoReply: get_text and get_attribute('innerText') return html > > > Greetings, > > This message has been automatically generated in response to the creation of a trouble ticket regarding: > "get_text and get_attribute('innerText') return html", a summary of which appears below. > > There is no need to reply to this message right now. Your ticket has been assigned an ID of [rt.cpan.org #131000]. Your ticket is accessible on the web at: > > https://rt.cpan.org/Ticket/Display.html?id=131000 > > Please include the string: > > [rt.cpan.org #131000] > > in the subject line of all future correspondence about this issue. To do so, you may reply to this message. > > Thank you, > bug-WWW-Mechanize-Chrome@rt.cpan.org > > ------------------------------------------------------------------------- > use Log::Log4perl qw(:easy); > use WWW::Mechanize::Chrome; > use Data::Dumper; > Log::Log4perl->easy_init($ERROR); # Set priority of root logger to ERROR my $mech = WWW::Mechanize::Chrome->new(); $mech->get('https://metacpan.org/pod/WWW::Mechanize::Chrome::Node'); > my $node = $mech->xpath('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a',single=>1); > print $node->get_text()."\n"; > print $node->get_attribute('innerText')."\n"; > my ($val,$type) = $mech->eval("document.evaluate('/html/body/div[1]/div[2]/div/div/div[1]/span[1]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerText"); > print "What I expect: $val\n"; > > <span itemprop="name">Max Maischein</span> <span itemprop="name">Max Maischein</span> What I expect: Max Maischein >
I've just released 0.40, which addresses (and now tests for) this bug. Thanks for the report and the good solution!