lpowers has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

While using the $mech->click function in WWW::Mechanize::Chrome, I frequently see the following warning:

Use of uninitialized value in string eq at /usr/local/share/perl5/WWW/ +Mechanize/Chrome.pm line 1279.
This error is generated from $mech->click lines like this:
$mech->click( { selector => '#dcrd-31 > div > div > div:nth-child(1)', + single => 1 } );
or this:
$mech->click( { xpath => '//*[@id="dcrd-31"]/div/div/div[1]', single = +> 1 } );
Most of the time this line works fine:
$mech->click( { selector => '#signIn', single => 1 } );
But occasionally, I get the "Use of uninitialized value..." warning from it as well (sometimes 2 successive warnings).

I'm guessing that a non-alphanumeric character in the ->click selector/xpath is throwing things off.

Do I need to escape certain characters or do I need to change the selector/xpath format or am I barking up the wrong tree?

Thanks much!

2018-09-05 Athanasius added code tags

Replies are listed 'Best First'.
Re: WWW::Mechanize::Chrome ->click giving warning
by Corion (Patriarch) on Aug 30, 2018 at 07:37 UTC

    The error occurs in Line 1279, so most likely in the request there is no requestId field set.

    This has little to do with the code you are running and more with whether the element you click on navigates within the page or whether it triggers a network/navigation request.

      So it sounds like the cause of the warning is not something I can control and likely doesn't affect the way the program works.

      As always, thanks for your prompt and helpful replies. It's much appreciated!