libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 53 forks source link

Click Button is not working using Mechanize Module #254

Closed CS00460960 closed 5 years ago

CS00460960 commented 6 years ago

Hi,

I'm trying to click the button using Mechanize Module . It Gives error that NO CLICKABLE INPUT WITH NAME shutdown at /home/(moodule path/ at line no: ..

Please Help. If there are any other way to click this dropdown . Please Suggest

HTML page:

<button type='button' onclick='return showMenu(this,event);return false;' name='Shutdown' class="formMenuButton">Shutdown<span>&nbsp;</span></button>&#160;<div class='button-menu-outer'><div class='menudstr'></div><div class='menudsbl'><div class='menuds'><ul  class='button-menu'>**
          <li onmouseout='buttonMenuMouseOut(this);' onmouseover='buttonMenuMouseOver(this);'  onclick='disableButtons();switchPortlet("CoreServerShutdownServer","CoreServerShutdownServerPortlet","serverControlStartstopForm");return false;'><a href="#">When work completes</a></li>
          <li onmouseout='buttonMenuMouseOut(this);' onmouseover='buttonMenuMouseOver(this);'  onclick='disableButtons();switchPortlet("CoreServerForceShutdownServer","CoreServerForceShutdownServerPortlet","serverControlStartstopForm");return false;'><a href="#">Force Shutdown Now</a></li>

My Code:

$mech->click_button(name=>'Shutdown')
$mech->click_button(name=>'When work completes")
CS00460960 commented 6 years ago

html page format.txt

Please Check html format for details

oalders commented 6 years ago

There's not enough context here for me to say whether this is a bug or a problem with your code. Please post enough code for us to reproduce exactly what you're seeing. For instance, it's not clear to me whether you're actually selecting a form, whether there is more than one form on the page, etc.

The best thing you can do is provide enough Perl + HTML so that we can run the same code and see the same problem.

CS00460960 commented 6 years ago

Hi @oalders , I am login to server and go to this HTML Start Stop Control Page Provided below . Under form name "serverControlStartstopForm" there was an dropdown under Shutdown button(When Work Completes) . I need to click this dropdown button

My Code:

use strict;
use warnings;

use Net::OpenSSH;
use WWW::Mechanize;

my $url = "http://p1gio1z9.vci.att.com:40000/console/login/LoginForm.jsp";
my $username = "########";
my $password = "#########";
my $mech     = WWW::Mechanize->new();
$mech->cookie_jar( HTTP::Cookies->new() );

$mech->get($url);
print $mech->title() . "\n";
$mech->submit_form(
    with_fields => {
        "j_username" => $username,
        "j_password" => $password,
    }
);

$mech->get(
    "http://p1gio1z9.vci.att.com:40000/console/console.portal?_nfpb=true&_pageLabel=ServerControlTabcontrolTabPage&handle=com.bea.console.handles.JMXHandle%28%22com.bea%3AName%3D"
        . $srv
        . "%2CType%3DServer%22%29" );
my $name = 'serverControlStartstopForm';
$mech->form_id($name);
$mech->click_button( name => "Shutdown" );
$mech->click_button( name => "When Work Completes" );

Html Page: [Html Control Start Stop Page.txt](https://github.com/libwww-perl/WWW-Mechanize/files/2349056/Html.Control.Start.Stop.Page.txt

oalders commented 5 years ago

Sorry I'm just getting back to this. The above code sample wouldn't compile, so I made a few tweaks. $srv is still not being defined, though.

I'm going to close this ticket as I'm not seeing a bug in the module. Feel free to re-open if you find a bug. Otherwise asking this kind of question on stackoverflow.com is probably the best way to get a fast answer.

CS00460960 commented 5 years ago

Please Check the full code i have attached.. Every variable is defined Mech Click issue.txt