in reply to Re^8: WWW::Mechanize::Chrome Instagram
in thread WWW::Mechanize::Chrome Instagram

Without seeing the HTML and Javascript, it's hard to know what the page does wrong so that clicking in the form fields get filled but the button does not get unblocked.

If by "the content is empty" you mean that the input you type is not visible in the form fields, then either that does not work or you are not clicking on the correct fields.

You can indirectly watch your browser as it progresses by using the screencast feature. See Mojolicious::Plugin::PNGCast for something that will display a window of your headless browser page.

Replies are listed 'Best First'.
Re^10: WWW::Mechanize::Chrome Instagram
by damian1 (Novice) on Sep 08, 2019 at 20:12 UTC

    okay i have screenshot, this is crazy result

    For code :

    if ($mech->success()) { $mech->sleep(1); + # waiting for load site $mech->form_number(1); $mech->value( username => $user ); $mech->value( password => $pass ); $mech->sleep(1); show_screen($mech); }

    Result image:

    https://imgur.com/a/hacCoB0

    For code :

    if ($mech->success()) { $mech->sleep(1); + # waiting for load site $mech->click({xpath => '//input[@name="username"]', single => +1 }); $mech->sleep(1); $mech->sendkeys( string => "test\r" ); $mech->sleep(1); $mech->click({xpath => '//input[@name="password"]', single => +1 }); $mech->sleep(1); $mech->sendkeys( string => "test\r" ); $mech->sleep(1); show_screen($mech); }

    Result image:

    https://imgur.com/a/uUcsPi2

    The first example shows that the button has not been activated and value are on the label, the label should disappear

    Second example shows click not work, input is empty although the rules are correct, the module finds these fields (username and password) Maybe not work sendkeys? Did I write it correctly sendkey function?

    HTML code on instagram, input

    <input class="_2hvTZ pexuQ zyHYP" aria-label="Phone number, username, +or email" aria-required="true" autocapitalize="off" autocorrect="off" + maxlength="75" name="username" type="text" value=""> <input class="_2hvTZ pexuQ zyHYP" aria-label="Password" aria-required= +"true" autocapitalize="off" autocorrect="off" name="password" type="p +assword" value=""

    Why sendkeys not work on this input?

      From the image, it seems that the website does not use the real <input> fields as input but uses other fields overlaid over these fields. To verify this, I would inspect the HTML elements that get notified when clicking on that location on screen.

      Maybe you can even get by with driving the whole thing with the keyboard alone. Count how many times you need to ->sendkeys("\t") to switch the focus to the appropriate field and then send the input. This is much more fragile, but it seems that the "normal" way doesn't work well there.

        when i use

        $mech->sendkeys("\t");

        I get error message

        Odd name/value argument for subroutine at engine.pl line 71.

        I try with string param

         $mech->sendkeys(string => "\t");

        Not work, no effect, no select input

        How use properly sendkeys to tab key?

      Hello, sorry I'm also still learning Perl/programming, and I have never used any WWW::Mechanize modules, but I'm curious, and after looking at the Instagram login page with firefox devtools I would suggest simulating more page interaction, like what happens if you 'click' the user name input field with:

      $mech->click({xpath => '//input@name="username"', single => 1 });
      then fill the input field value with:
      $mech->value( username => $user );
      then 'click' Log In.

      I also want to say it looks to me like the Javascript 'events' are what is preventing a simple solution here, and by simple I suppose I mean something that seems obvious to someone like me who doesn't really know javascript. Hope that may help, sorry if it was just wasting time, but I am curious to see if that would at least make the label go away in the first picture/example :)

        thanks for Your reply, i try but the label is still visible