Re: mech and javascript modifying form post action
am 08.11.2006 17:08:18 von edaly
Each form is represented as an HTML::Form object, so you
could manipulate the form directly using those methods:
my $form = $mech->form_number(2);
$form->action(URI->new_abs('somewhere_else.aspx?appended_stu ff',
$mech->uri));
$mech->submit_button(form_number => 2);
The action method requires a full URI, so that's what the
"URI->new_abs" part provides.
Otherwise, you could apply the large stone hammer approach of
rewriting the HTML yourself using the update_html method:
my $html = $mech->content;
$html =~
s{\Qaction="start.aspx"}
{action="somewhere_else.aspx?appended_stuff"};
$mech->update_html($html);
$mech->submit_button(form_number => 2);
____________________________________________________________
Eamon Daly
----- Original Message -----
From: "Neville Aga"
To:
Sent: Tuesday, November 07, 2006 9:36 PM
Subject: mech and javascript modifying form post action
I am using mech to fill out a form. The problem is javascript is used to
alter the form before it is submitted. That is the html of the form
initially has
method=post action=somewhere_else.aspx?appended_stuff>. Since mech does
not understand javascript I cant simply click() or submit().
So, how do I fill out the form in mech and then change the target before
I use click() or submit? I can use standard perl to get somewhere_else
and appended_stuff, so that's not the problem. The problem is that I
don't know how to change mechs understanding of the form before
submission.
Any ideas?
Thanks,
Neville
RE: mech and javascript modifying form post action
am 09.11.2006 00:11:55 von Neville
------_=_NextPart_001_01C7038B.F23E0EA0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Thanks!! That is just what I was looking for. I used your 2nd =
implementation (large stone hammer with update_html ) as that seemed =
more intuitive to me.
I'd suggest to anyone wanting to work javascript code actions into mech =
to use this method. It worked like a charm.
Cheers, Neville=20
-----Original Message-----
From: Eamon Daly [mailto:edaly@nextwavemedia.com]
Sent: Wed 11/8/2006 10:08 AM
To: Neville Aga; libwww@perl.org
Subject: Re: mech and javascript modifying form post action
=20
Each form is represented as an HTML::Form object, so you
could manipulate the form directly using those methods:
my $form =3D $mech->form_number(2);
$form->action(URI->new_abs('somewhere_else.aspx?appended_stu ff',=20
$mech->uri));
$mech->submit_button(form_number =3D> 2);
The action method requires a full URI, so that's what the
"URI->new_abs" part provides.
Otherwise, you could apply the large stone hammer approach of
rewriting the HTML yourself using the update_html method:
my $html =3D $mech->content;
$html =3D~
s{\Qaction=3D"start.aspx"}
{action=3D"somewhere_else.aspx?appended_stuff"};
$mech->update_html($html);
$mech->submit_button(form_number =3D> 2);
____________________________________________________________
Eamon Daly
----- Original Message -----=20
From: "Neville Aga"
To:
Sent: Tuesday, November 07, 2006 9:36 PM
Subject: mech and javascript modifying form post action
I am using mech to fill out a form. The problem is javascript is used to
alter the form before it is submitted. That is the html of the form
initially has
method=3Dpost action=3Dsomewhere_else.aspx?appended_stuff>. Since mech =
does
not understand javascript I cant simply click() or submit().
So, how do I fill out the form in mech and then change the target before
I use click() or submit? I can use standard perl to get somewhere_else
and appended_stuff, so that's not the problem. The problem is that I
don't know how to change mechs understanding of the form before
submission.
Any ideas?
Thanks,
Neville
------_=_NextPart_001_01C7038B.F23E0EA0--