Hi,
I am trying to automate a form submission using WWW::Mechanize::Firefox. Populating the form works just fine as expected. But on submitting the form with the function $mech->click_button(), a javascript alert box gets opened. Without preventing the alert box opening, form submission does not happen.
Please find the HTML which opens the confirm dialog box.
<form onsubmit="return onSubmitProfile(this,'Please complete the red e +ntry.','Warning: Incorrect parameters may cause undesired behavior.') +" method="post" action="/goform/formHandlerConfigureProfileSettings"> <table width="100%" bgcolor="#ffffff" align="middle" valign="top"> </table> <fieldset> </fieldset> <fieldset id="content" style="display: none;"> </fieldset> <table > <tbody> <tr cellpadding="6" cellspacing="6" width="100%"> <td width="5%"> </td> <td width="45%"> </td> <td width="50%"> <input type="submit" value="Apply" name="button"> </td> </tr> </tbody> </table> </form>
The javascript function for the same is
function onSubmitProfile(theform,errorMessage,confirmMessage) { if(validateIpSettings() != 0) {alert(errorMessage); return false} var submitConfirm=confirm(confirmMessage) if(submitConfirm==true) { return true } return false }
As a work around for this issue, I used $mech->submit to submit the form by avoiding javascript. But this also avoid the error checking withing the web page. So can anyone help me here to trap the alert message which is displayed during the form submission. Also I tried to trap the alert with the function $mech->eval_in_page. But I could not find any detailed examples to use this function for the same purpose.
Any suggestions in this issue is appreciated.
In reply to (OT) How to override the javascript alert when submitting a form using WWW::Mechanize::Firefox by ajose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |