Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

How to automate a form with javascript

by romy_mathew (Beadle)
on Jul 26, 2012 at 17:38 UTC ( #983890=perlquestion: print w/replies, xml ) Need Help??
romy_mathew has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I was trying to automate an sms function with free sms site "". I am having a problem in submitting a form with java action at the message page

I am posting the code I was trying to achive below.

#!/usr/bin/perl -w use strict; use WWW::Mechanize; my $browser = WWW::Mechanize->new(); $browser->agent('User-Agent=Mozilla/5.0 (Macintosh; U; Intel Mac OS X +10.5; en-US; rv: Gecko/20091102 Firefox/3.5.5'); my $url =''; my $result = $browser->get($url); die "GET failed" unless $result->is_success; print "Opned the Login Page\n"; $result = $browser->submit_form( form_number => 1, fields => { username => '9400791900', password => '123456' } ); die "SUBMIT FAILED" unless $result->is_success; print "Passed the Login Page\n"; my $message = $browser->get(' +9AEE54A1FBAE529AE0AA48A6.03'); die "URL Follow failed" unless $message->is_success; print "sucessfully login inside the Message Page\n"; print "printing the current page fetched \n"; =comment open ("FILE","> log.txt") or die "cannnot able to open the file for wr +itting\n"; print FILE $browser->content; close(FILE); $message = $browser->submit_form( form_name => 'frm_sendsms', fields => { mobile1 => '9400791900', msg1 => 'Hello a Test Message from romy', btnsendsms => 'Send Now' } ); =cut $browser->form_name("frm_sendsms"); $browser->field("mobile1","9400791900"); $browser->field("msg1","Hi Dear I am from lap"); $browser->submit(); die "SUBMIT FAILED" unless $browser->success(); print "Passed the Message Page\n";

Replies are listed 'Best First'.
Re: How to automate a form with javascript
by zentara (Archbishop) on Jul 26, 2012 at 17:53 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://983890]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-02-22 09:55 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (289 votes). Check out past polls.