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

Hello Everyone

I'm facing an issue while clicking the button after login to the webpage

What I want to do is , First login to the webpage then click the OK button. I'm using WWW::Scripter(plugin javascript) as login page is using javascript while loading.

Here is the code that I have tried

use strict; use warnings; use WWW::Scripter; my $username = "abc"; my $password = "abc\@123"; my $w= WWW::Scripter->new( cookie_jar => { autosave => 1} ); $w->use_plugin('JavaScript'); $w->get('abc.xyz.com'); $w->submit_form( with_fields => { username => $username, password => $ +password }); print $w->title(); #Till here it is working, I'm able to login ############## Clicking OK button ################ $w->click(name=>'successOK'); print $w->title(); #it is giving me that no clickable button with name successOK

Here is OK button code

<div id="srv_successok"><input type="button" name="successOK" value=" + OK " onClick="redir();"></div>

Please suggest how can I resolve it

Thank you

Replies are listed 'Best First'.
Re: No Clickable button with name.... in WWW::Scripter
by Corion (Patriarch) on Jun 28, 2017 at 19:41 UTC

    Have you made certain that the button successOK is within a <form> element?

      Yes, successOK is in <form> element

      .

        Ah, now I see.

        After a quick source dive, WWW::Scripter does not support <input type="button" for ->click:

        sub click { ... my $input; my $form = $self->current_form; for ($form->inputs) { next unless $_->type =~ /^(?:submit|image)\z/; next if $button && $_->name ne $button; next if $_->disabled; $input = $_; last; } Carp::croak("No clickable input with name $button") if $button && !$input; ...

        You might want to report this as a bug via the bug tracker, but as a workaround, consider changing the code, so that it also can click on a button:

        next unless $_->type =~ /^(?:submit|image|button)\z/;