On 1/15/06, Ankur Gupta <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a very simple WWW::Mechanize perl program which does the following 
> task.
> 1. Gets the login URL.
> 2. Enters username and password.
> 3. Get another URL.
> 4. Fill some fields of date range and submit.
> 5. Parse the content and create a report.
>
> It used to work until the web designer changed the form fields, added
> some javascript and the program stopped working.
>
> So I changed my program(basically the form fields), but I am unable to
> get the *content* in #4. Infact the content is same as the content of
> #3.
>
> After googling, reading the docs, trying out things for hours, I am
> unable to crack it :((.
>
> Following are the form fields which I get from the program. Which
> seems identical to the fields in the html source.
> option: orderdaterangeinputstore:st : 14
> option: orderdaterangeinputstore:star : 01
> option: orderdaterangeinputstore:sta : 2006
> option: orderdaterangeinputstore:end : 15
> option: orderdaterangeinputstore:endm : 01
> option: orderdaterangeinputstore:endy : 2006
> submit: orderdaterangeinputstore:_id11 :
> hidden: orderdaterangeinputstore:merchantID : 100106
> hidden: orderdaterangeinputstore:statusID : 2109
> hidden: jsf_tree_64 :  <very_long_string_hash>
> hidden: jsf_state_64 : <very_long_string_hash>
> hidden: jsf_viewid : /merchant/merchantDateRange.jsp
> hidden: orderdaterangeinputstore_SUBMIT : 1
> hidden: orderdaterangeinputstore:_link_hidden_ :
>
> Following is the code and I have attached the html source of #3.
>
> use strict;
> use warnings;
>
> use WWW::Mechanize;
> my $mech = WWW::Mechanize->new();
>
> my $url = "login_url";
> $mech->get($url);
>
> $mech->set_fields(
>     '_id0:_id8' => 'user',
>     '_id0:_id12' => 'password'
> );
> $mech->click();
>
> $mech->get('another_url');
>
> $mech->set_fields(
>     'orderdaterangeinputstore:endy' => 2006,
>     'orderdaterangeinputstore:endm' => '01',
>     'orderdaterangeinputstore:end' => 15,
>     'orderdaterangeinputstore:sta' => 2006,
>     'orderdaterangeinputstore:star' => '01',
>     'orderdaterangeinputstore:st' => 14
> );
>
> $mech->click();
> print $mech->content;

I see the following javascript code in the login page....

Login page......
<input id="_id0:_id14" name="_id0:_id14" type="image"
src="../images/submit.gif" onclick="clear__5Fid0();"/>

[...]

<!--
function clear__5Fid0() {
  var f = document.forms['_id0'];
  f.elements['_id0:_link_hidden_'].value=null;
  f.target='';
}
clear__5Fid0();
//-->

-------

DateRange Page

[...]

<input id="orderdaterangeinputstore:_id11"
name="orderdaterangeinputstore:_id11" type="submit"
onclick="clear_orderdaterangeinputstore();" title="Submit"/>

[...]

<!--
function clear_orderdaterangeinputstore() {
  var f = document.forms['orderdaterangeinputstore'];
  f.elements['orderdaterangeinputstore:_link_hidden_'].value=null;
  f.target='';
}
clear_orderdaterangeinputstore();
//-->

---

What my question is whether there is any connection between
_link_hidden_ field between the login page and the other page.

I have tried setting _link_hidden_ field to undef/null value
before/after $mech->click is called but did not help.

Another question is whether $mech->click calls the javascript function
clear_orderdaterangeinputstore (onclick).

Thanks,

--Ankur

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to