tel2 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to automate reporting of song usage on a website, but can't even get WWW::Mechanize::PhantomJS to click the "SIGN IN" button by id. The code doesn't fail with any errors, but I can see it hasn't worked by rendering the page to a PNG file then manually viewing it. Here's my code so far:
The ccli_login.png file ends up containing the login screen with my email and password filled in, as if "SIGN IN" hasn't been clicked yet.use WWW::Mechanize::PhantomJS; my $mech = WWW::Mechanize::PhantomJS->new(); $mech->get('https://profile.ccli.com/account/signin?appContext=OLR&ret +urnUrl=https%3A%2F%2Freporting.ccli.com%2F'); $mech->field( EmailAddress => 'me@test.com' ); $mech->field( Password => 'mypw' ); # This doesn't seem to work $mech->click_button( id => 'sign-in' ); # Each of these didn't work either, so I've commented them out #$mech->click_button( number => 1 ); #$mech->click({ xpath => '//button' }); #$mech->submit_form(); # This didn't work either, so I've commented it out #$mech->submit_form( # with_fields => { # EmailAddress => 'me@test.com', # Password => 'mypw' # } #); $mech->render_content( format => 'png', filename => 'ccli_login.png' );
Any ideas what I'm doing wrong? Feel free to experiment with any email address & password you like. It should give an error like "Email or password not found. ...etc..." if your code is able to click the "SIGN IN" button.
I'm running WWW::Mechanize::PhantomJS 0.24 and phantomjs 2.1.1.
Thanks.
tel2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize::PhantomJS can't click button
by bliako (Abbot) on Apr 28, 2021 at 08:39 UTC | |
by tel2 (Pilgrim) on Apr 28, 2021 at 22:35 UTC | |
by bliako (Abbot) on Apr 29, 2021 at 09:19 UTC | |
by tel2 (Pilgrim) on Apr 29, 2021 at 23:28 UTC | |
by bliako (Abbot) on Apr 30, 2021 at 07:34 UTC | |
| |
by Anonymous Monk on Apr 29, 2021 at 01:47 UTC | |
by tel2 (Pilgrim) on Apr 29, 2021 at 22:14 UTC |