How to input text into Facebook's event form with WWW::Mechanize::Firefox?
<p>Facebook has no API for submitting an event to a Facebook page. So I'm attempting to use WWW::Mechanize::Firefox with this script.</p>

<pre><code>use strict;
use warnings;
use feature qw(say);
use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox-&gt;new(activate =&gt; 1); 
$mech-&gt;autoclose_tab(0);
$mech-&gt;get('http://facebook.com');

if ($mech-&gt;title eq 'Facebook - Log In or Sign Up') {
  $mech-&gt;submit_form(
    with_fields =&gt; {
      email    =&gt; 'my@email.com',
      pass =&gt; 'my_password',
    }   
  );  
}
sleep(1);

$mech-&gt;get('https://www.facebook.com/PageName/events');
my $page_id = 777777777777777;

$mech-&gt;click({ synchronize =&gt; 0, xpath =&gt; '//a[text() = "Create Event"]' }, 10, 10);
sleep(3);

# selects all input fields and sets value to 'hello world'
# even though values are set, the fields remain blank
my @selectors = $mech-&gt;selector('input');
foreach my $selector (@selectors) {
  $mech-&gt;field( $selector, 'hello world');
}

# attempts to publish event, results in form errors because fields are blank
$mech-&gt;click({ synchronize =&gt; 0, xpath =&gt; '//button[text() = "Publish"]' });

# test to see if values are getting set.
# this returns 'hello world' as so values are getting set
say $mech-&gt;value($selectors[2]); 

# test to see if an input field can be selected with an xpath
# this works
$mech-&gt;click({ synchronize =&gt; 0, xpath =&gt; '//input[@placeholder="Include a place or address"]' });
</code></pre>

<p>The form generated by Facebook does not make it easy to input data into the text fields. The fields have no name property and they are not distinguishable with a css selector (though they can be selected with an xpath) as seen in last line.</p>

<p>Because there is no way to input text into the fields, Facebook throws errors because it sees the fields as blank even though I successfully put values into the fields using <code>$mech-&gt;field</code>.</p>

<p>Is there any way to get text into Facebook's form for adding events?</p>

<p><strong><em>UPDATE</em></strong>
I made a little progress on this. I was able to at least get some of the fields filled out (<code>Event name</code> and <code>Location</code>) using this code:</p>

<pre><code>my $field = $mech-&gt;xpath( '//input[@placeholder="Include a place or address"]', one =&gt; 1);
$field-&gt;{value} = 'Room 315, City Hall';

$field = $mech-&gt;xpath( '//input[@placeholder="Add a short, clear name"]', one =&gt; 1);
$field-&gt;__click;
$field-&gt;{value} = "License committee meeting";
</code></pre>

<p>Unfortunately, when I click on the "Publish" button with this code:</p>

<pre><code>$mech-&gt;click({ synchronize =&gt; 0, xpath =&gt; '//button[text() = "Publish"]' }, 10, 10);
</code></pre>

<p>the <code>Event Name</code> and <code>Location</code> text fields get cleared as if nothing was entered. Not sure what else to try at this point.</p>