Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

WWW::Mechanize::Firefox button click problem HP iLO

by ruzam (Curate)
on Jul 24, 2015 at 16:55 UTC ( #1136204=perlquestion: print w/replies, xml ) Need Help??

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

I think I've reached the end of my quest here. This is not the usual 'freeze after click' problem searching keeps finding for me.

I'm working on scripting automated interfaces to HP iLO logins using WWW::Mechanize::Firefox. For the most part, things are falling into place as expected. Navigating login, getting to information tabs, pulling information out of the html. But I'm having one unexplainable problem with the logout button. I have different versions of iLO to interface with - 2, 3 and 4. The web layout and design for 3 and 4 are very similar. They both have the same page layout, included javascript, and design. The logout button design in particular is identical for both, except for one small detail. Version 3 uses an onclick event, while Version 3 uses an onmouseup event

(version 3) <a id="home_link" rel="localize[masthd.home]" onclick="iLO.openLink("s +ummary.html");this.blur();return false;" href="summary.html">Home</a> | <button id="logout_button" rel="localize[masthd.signout]" onclick="iLO +.doLogout();">Sign Out</button>
(version 4) <a id="home_link" rel="localize[masthd.home]" onclick="iLO.openLink("s +ummary.html");this.blur();return false;" href="summary.html">Home</a> | <button id="logout_button" rel="localize[masthd.signout]" onmouseup="i +LO.doLogout();">Sign Out</button>

For iLO version 3 I can activate the logout button as expected with:

$mech->click_button(id => 'logout_button');

But that same action on iLO version 4 does nothing. Seems nothing I do will activate the button. I've tried $mech->click with the appropriate xpath keys, I've tried using $mech->by_id to get the node, followed by $node->click. I've also tried $mech->follow_link( tag => 'button', id => 'logout_button' );

If I try $mech->eval('iLO.doLogout();'), I get:

(in cleanup) MozRepl::RemoteObject: ReferenceError: iLO is not defined + at ...

I can find and retrieve the logout button node and manipulate it without errors, but it just doesn't do anything. I guess I should expect that being that it has no onclick handler. If I check the page for $mech->clickables, it clearly shows both 'Home' and 'Sign Out' for version 3, but only 'Home' for version 4.

What can I do to trigger this event? Is there any way to send an onmouseup event with WWW::Mechanize::Firefox? Maybe some hoops I can jump through to execute the javascript doLogout() function directly?

Replies are listed 'Best First'.
Re: WWW::Mechanize::Firefox button click problem HP iLO
by Corion (Pope) on Jul 24, 2015 at 17:02 UTC

    Maybe you can simulate the event by calling the ->__event() method on the element:

    my $el = $mech->by_id('logout_button'); $el->__event('mouseup');

      Fantastic! That's exactly what I needed! Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1136204]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2020-10-31 05:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (286 votes). Check out past polls.

    Notices?