After trying a lot I still have no idea how I can execute this post method with WWW::Mechanize::PhantomJS. It uses javascript on onsubmit="_onlickWeiter()"
<form name="NeuerMBAntrag" action="Mahnantrag" method="post" onsubmit="_onclickWeiter()">
<input name="_ts" value="1464398188768" type="hidden">
<input name="Command" value="neuerMBAntrag" type="hidden
_onClickWeiter()
function _onclickWeiter()
{
document.NeuerMBAntrag.Command.value = "neuerMBAntragForce" ;
document.NeuerMBAntrag.submit() ;
}
If I call $mech->submit()
it does not load.
The website has only buttons and no input fields, there are two buttons on the page inside the <form></form>
tag.
Button 1:
<input src="images/butt_neuerAntrag_120x19.gif" name="neuer Antrag" alt="Weiter mit neuem Antrag, alte Eingaben gehen verloren (Alt+N)" accesskey="n" tabindex="2" border="0" type="image">
$mech->click('neuer Antrag');
does not work.
<form name="NeuerMBAntrag" action="Mahnantrag" method="post" onSubmit="_onclickWeiter()">
<input type="hidden" name="_ts" value="1464399779271" />
<input type="hidden" name="Command" value="neuerMBAntrag">
<table border="0" cellspacing="0" width="750">
<tr bgcolor="#666666">
<td width="10"> </td>
<td width="10"> </td>
<td width="10"> </td>
<td width="80"> </td>
<td width="10"> </td>
<td width="320"> </td>
<td width="110"> </td>
<td width="110"> </td>
</tr>
<tr bgcolor="#666666">
<td colspan="2"> </td>
<td class="zeile1" colspan="4">Antrag auf Erlass eines Mahnbescheids</td>
<td colspan="2" align="right"><table cellspacing="1" cellpadding="1">
<tr>
<td><img src="images/ico_bevollmaechtigter_off.gif" alt="Prozessbevollmächtigter (noch keine Angaben)" title="Prozessbevollmächtigter (noch keine Angaben)"></td>
<td><img src="images/ico_antragsteller_off.gif" alt="Antragsteller (noch keine Angaben)" title="Antragsteller (noch keine Angaben)"></td>
<td><img src="images/ico_antragsgegner_off.gif" alt="Antragsgegner (noch keine Angaben)" title="Antragsgegner (noch keine Angaben)"></td>
<td><img src="images/ico_forderung_off.gif" alt="Hauptforderung/Zinsen (noch keine Angaben)" title="Hauptforderung/Zinsen (noch keine Angaben)"></td>
<td><img src="images/ico_nebenforderung_off.gif" alt="Auslagen und Nebenforderungen (noch keine Angaben)" title="Auslagen und Nebenforderungen (noch keine Angaben)"></td>
<td><img src="images/ico_allgemein_antrag_off.gif" alt="Allgemeine Angaben (noch keine Angaben)" title="Allgemeine Angaben (noch keine Angaben)"></td>
<td><img src="images/ico_datenuebersicht_off.gif" alt="Datenübersicht" title="Datenübersicht"></td>
<td><img src="images/ico_drucken_off.gif" alt="Druck" title="Druck"></td>
</tr>
</table></td>
</tr>
</table>
<table border="0" cellspacing="0" width="560">
<tr>
<td width=10></td>
<td width=300></td>
<td width=240></td>
<td width=10></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2" class="literal" align="right" valign="bottom"><a><img src="images/butt_hilfe.gif" border="0" alt="Einführung" onClick="hilfe('hilfe/einfuehrung.htm')"></a> </td>
</tr>
<tr>
<td class="text"> </td>
<td class="text" colspan="2">
<p>Der Antrag auf Erlass eines Mahnbescheids ist in 8 Schritte aufgeteilt.
<ol>
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_bevollmaechtigter_on_mini.gif'> Prozessbevollmächtigten erfassen (sofern vorhanden)
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_antragsteller_on_mini.gif'> Antragstellerdaten erfassen
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_antragsgegner_on_mini.gif'> Antragsgegner erfassen
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_forderung_on_mini.gif'> Anspruch/Forderung erfassen
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_nebenforderung_on_mini.gif'> Auslagen und Nebenforderung erfassen (sofern vorhanden)
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_allgemein_antrag_on_mini.gif'> Allgemeine Angaben zum Antrag
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_datenuebersicht_on_mini.gif'> Überprüfen der Antragsdaten
<li>Schritt: <img src='https://www.online-mahnantrag.de:443/omahn/images/ico_drucken_on_mini.gif'> Druck/Antragsabgabe
</ol>
</p>
<p>Geben Sie zu jedem Schritt die erforderlichen Daten ein. Mit <img src="images/butt_weiter_rund_klein.gif" width=13 height=13 alt="" border="0"> bestätigen Sie Ihre Eingabe und gelangen zum jeweils nächsten Schritt oder Teilschritt.</p>
<p>Haben Sie schon Daten erfaßt, möchten aber von vorne beginnen, so betätigen Sie "Neuer Antrag" auf dieser Seite. Alle bisher erfassten Daten werden dann gelöscht.</p>
<td class="text"> </td>
</tr>
<tr>
<td> </td>
<td class="text">
<a href="/omahn/Mahnantrag?_ts=9161743-1464399779271&Command=showBundesland" target="main" accesskey="z" tabindex=3><img src="images/butt_zurueck_60x19.gif" border="0" alt="Zur Auswahl des Bundeslandes (Alt+Z)" ></a>
<!-- <p>Wir wünschen Ihnen viel Spaß bei der Eingabe Ihrer Daten.</p>-->
</td>
<td align="right" height=40 id="." valign="BOTTOM" width=".">
<a href="/omahn/Mahnantrag?_ts=9161744-1464399779271&Command=neuerMBAntrag" target="main"><img src="images/butt_weiter_60x19.gif" border="0" name="weiter" alt="Weiter, der aktuelle Antrag bleibt erhalten (Alt+W)" accesskey="w" tabindex=1></a>  
<input type="image" src="images/butt_neuerAntrag_120x19.gif" border="0" name="neuer Antrag" alt="Weiter mit neuem Antrag, alte Eingaben gehen verloren (Alt+N)" accesskey="n" tabindex=2>  </td>
<td class="text"> </td>
</tr>
</table>
</form>
It looks like the _onClickWeiter() adds another variable document.NeuerMBAntrag.Command.value = "neuerMBAntragForce" ;
and then submits. How would I call this with WWW::Mechanize:PhantomJS the easiest way without loss of <input></input>
fields inside <form></form>
It seems I have solved the problem. The page is using multiple frames. $mech->submit() is working fine on this form, but only if I select the correct frame.
sub f { my $mech = shift; my @frames = $mech->expand_frames(); return $frames[2]; };
$mech->activate_container(f( $mech ));
It seems $frames[2]
holds the content of the submit form. Once selected $mech->submit()
is working fine.
All my previous tries were inside the header iframe, that holds literally just a bold heading line.