Hi Monks,

I haven't used WWW::Mechanize much, and I'm trying to get it to login to a site and make an entry. I can see that the logging on part is working fine, but there's a button that I want to click, and I'm not sure of the cleanest way to do that. Firefox's Firebug shows me that the code behind the button that I want to click looks like this:

<button class="button small" onclick="ga('send','event', 'Add CCL Acti +vity', 'Select', 'Add to Report button in Search Results')" type="sub +mit">Add to Report</button>
What's a clean way to click such a button? As you can see, it doesn't have a "name" attribute, and the "button small" class applies to several buttons on the webpage, so maybe I could click the Nth "button small" (right?), but is there a cleaner way to identify the field? One which won't break if they insert another "button small" above this one, perhaps? There are also several 'type="submit"' buttons on this webpage.

I've spent quite some time looking through the documentation and examples, and I can see various ways to click buttons, but nothing stands out as ideal for my situation, so I thought I should ask for expert advice.

Thanks.
tel2


In reply to Clicking a button with WWW::Mechanize by tel2

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.