All I want to do is click a login button to have the underlying JavaScript trigger and build the new web page. I just recently came back to Perl after, I don't know, 20 years? Anyway I got hung up on this little item for the last few days and would greatly appreciate some help. The code opens the website page in Firefox, and the button never gets clicked.
#!/usr/local/perls/perl-5.20.0/bin/perl use v5.10; use strict; use warnings; use diagnostics; use WWW::Mechanize::Firefox; use HTTP::Cookies; my $FEXdms = 'http://www.financeexpress.com/'; my $web_page = 'current'; my $mech = WWW::Mechanize::Firefox->new( tab => $web_page, activate => 1, # bring the tab to the foreground autoclose => 0 # to prevent autoclosing of the Tab ); $mech->get( $FEXdms ); $mech->click_button( name=> "btnLogin" );

---------------- results -----------------------------

Uncaught exception from user code: No elements found for //*(translate(local-name(.), "ABCDEFGHIJKLMNOPQRSTUVWX YZ", "abcdefghijklmnopqrstuvwxyz") = "button" and @name="btnLogin") or (translate(loc al-name(.), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")="input" and @ type="button" or @type="submit" and @name="btnLogin") at test.pl line 20.

WWW::Mechanize::Firefox::signal_condition(WWW::Mechanize::Firefox=HASH(0x2644 b94), "No elements found for //*[(translate(local-name(.), \"ABCDEFGH"...) called at C:/Perl/site/lib/WWW/Mechanize/Firefox.pm line 2640

WWW::Mechanize::Firefox::xpath(WWW::Mechanize::Firefox=HASH(0x2644b94), "//*[ (translate(local-name(.), \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \""..., "node", undef, "sin gle", 1, "user_message", "Button name 'btnLogin' unknown") called at C:/Perl/site/lib /WWW/Mechanize/Firefox.pm line 3065

WWW::Mechanize::Firefox::click_button(WWW::Mechanize::Firefox=HASH(0x2644b94) , "name", "btnLogin") called at test.pl line 20

---------------------------------------------------


In reply to can't click a simple button by backyardbill

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.