Battle_Fury has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys, I'm working on a web automation task for my company, accessing an HTTPS site, logging in & navigating through its pages and downloading certain files. I installed the relevant packages, like the WWW::Mechanize, Crypt::SSLeay etc. and was able to fill in forms, navigate & authenticate etc.. However, the problem I'm facing now is in a particular page where I have to fill a form and click on the submit button. A part of the HTML code goes like:
<Br> <Table Width=85% Align=Center border=0 cellspacing=1 cellpadding=1> <Tr> <Td Width=50% Align=Left> &NBSP; </Td> <Td Width=50% Align=Right> <Input Type=Button Name=CmdSearch Value="&NBSP;&NBSP;&NBSP +;Search&NBSP;&NBSP;>>" OnClick="javascript:Search();"> </Td> </Tr> </Table> </Center>
As you may notice, after I fill the form, I'm trying to click on this button named 'CmdSearch' so that it navigates to the next page. Problem though, I presume, is something to do with the "&NBSP". When I apply the script & save the web page on my comp, I can see the filled contents on the text boxes, however it seems like the button hasn't been clicked. This was when I tried the command in the submit_form function : "CmdSearch" => "&NBSP;&NBSP;&NBSP;Search&NBSP;&NBSP;>>" Infact, I removed the   & replaced with blank spaces, tried other combinations too but in vain. Also attempted is the click_button() function using various parameters like name, number , value etc. but again, the script appears to ignore the button in itself. Error messages like button name not found in header etc. display & the script terminates. Anyway, any advice to solve this issue would be, by me, greatly appreciated. Cheers P.S: Pls note that the "&NBSP" was deliberately put in CAPS in this post since the page treats it as a " " when displaying the message.

20070921 Janitored by Corion: Added code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Form submission - &NBSP??
by ForgotPasswordAgain (Vicar) on Sep 21, 2007 at 09:02 UTC
    Isn't the problem actually that WWW::Mechanize doesn't execute JavaScript? (the OnClick)
Re: Form submission - &NBSP??
by graff (Chancellor) on Sep 22, 2007 at 02:55 UTC
    It's entirely likely that the first reply is on the mark (I really don't know). But if you need to emulate a string that contains &nbsp; (as opposed to simply using the 6-character entity reference '&nbsp;'), you might try using "\xA0" for each instance of the nbsp entity. (I'm only guessing, but that would seem more appropriate than a plain-old space, which is "\x20").