2

I am trying to use WWW::Mechanize to fill out a form. Unfortunately my page requires JS so I am now using WWW::Mechanize::Firefox.

Here is the element I am trying to fill out.

<input id="ember745" class="ssTextboxField"></input>

The set_field() function takes an element name. How would I give it an element ID (ember 745) and have it fill the form in?

Here is my code so far

use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new(autoclose => 0);
$mech->get(URL);

$mech->form_number(1);
$mech->submit_form(
fields => {
    ember745 => $value
});
Bijan
  • 7,737
  • 18
  • 89
  • 149
  • 1
    I can't test right now, but you can use simple CSS selectors with the [`field`](https://metacpan.org/pod/WWW::Mechanize::Firefox#mech-field-selector-value-pre_events-post_events) method, e.g. `$mech->field('#ember745', $value);` I don't think you can do this with `set_fields`, which is called by `submit_form`. – ThisSuitIsBlackNot Sep 16 '15 at 20:17

1 Answers1

3

Figured it out, had to use a selector

my $field = $mech->selector('input.ssTextboxField', single => 1);
$mech->field( $field => $value );
Bijan
  • 7,737
  • 18
  • 89
  • 149