You keep asking the same question again and again (Is it possible to get the application messages What could be the best way to capture controls in a web page?). If you actually provided more information, such as the URL of the login page that you are trying to process, that would help us in helping you.
As others have said, the process of submitting user name and password is first triggered by the submit button attached to the form of the document. You have to examine the action of the submission form to figure out what happens next. It could be a Perl script, a PHP script, a shell script, an ASP process, or something else I'm not thinking of at the moment. If you don't control the source of the scripts that do the processing, you are limited in what you can do to try to automate the process.
Most importantly, what does "validate the error condition in this case" mean to you? The simplest way to handle the situation is to use WWW::Mechanize to submit the form information, collect the resulting HTML sent back from the server into a Perl variable, and look for the string "Incorrect user name/password"
|