[HtmlUnit] [htmlunit:bugs] #1962 FormSubmission not working - for log in

RBRi via HtmlUnit-develop <[email protected]> Sun, 24 Feb 2019 18:00:21 -0000
Newsgroups gmane.comp.java.htmlunit.devel
Message-ID </p/htmlunit/bugs/1962/4690d73fe468a1034fd88dbec376268e7cb36b21.bugs@htmlunit.p.sourceforge.net>
This is a multi-part message in MIME format.
--===============8950395393376733491==
Content-Type: multipart/related;
 boundary="===============2396990411513850537=="

This is a multi-part message in MIME format.
--===============2396990411513850537==
Content-Type: multipart/alternative;
 boundary="===============4286004074743566203=="
MIME-Version: 1.0

--===============4286004074743566203==
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit

- **status**: pending --> closed



---

** [bugs:#1962] FormSubmission not working - for log in**

**Status:** closed
**Group:** 2.30
**Labels:** input form submission 
**Created:** Fri May 11, 2018 04:13 PM UTC by Flake
**Last Updated:** Sun Feb 24, 2019 06:00 PM UTC
**Owner:** RBRi


I cannot get form submission to work on a login form. I've wasted hours and tried everything but there's no improvement whatsoever.

I've successfully used form submission for a search field - that worked as expected.
But for the login form HtmlUnit just does not seem to POST at all. Or it does and I do not manage to get the correct page.

I correctly retrieve the form and input elements.
I've tried setting the inputs (HtmlTextInput and HtmlPasswordInput) via `type()`, `setValueAttribbute()` and `setNodeValue()`.
I've tried submitting the form via getting the correct submit element and calling `page = submit.click();`, calling `page = (HtmlPage) username.type('\n');` and same for the password field.
I've tried getting the correct page by assigning the return value from `click()`, `type()` and also via `webClient.getCurrentWindow().getEnclosedPage()`. I also checked all windows - there were two but the second didn't seem to have a page ...
I've also waited for ages via `waitForBackgroundJavaScript()` and the other one as well as `Thread.sleep()` and have also tried the `NicelyResynchronizingAjaxController`.
I've tried `webClient.getOptions().setRedirectEnabled(true)` and `getCache().setMaxSize(0)`;

The page I try to log in to is this: https://www.dtad.de

When output the page I can see that the URL is still the root URL and that the input fields have the values that I set. So either the page wasn't submitted or I'm on the wrong page. The form action is what it's supposed to be (...validate.do). But here comes the even weirder thing:

When I try to log in via https://www.dtad.de/login I get the bad credentials message after form submit. So submission seems to work. But when I log in via the root page I should be forwarded to https://www.dtad.de/login (when entering bad credentials) but that does NOT happen. `page.asXml()` outputs the exact root page but with the input values set.

I'm really deperate and exhausted. I hope you can spot the mistake.
I've also checked if http -> https makes a difference but it ain't.

Best,
Flake


---

Sent from sourceforge.net because [email protected] is subscribed to https://sourceforge.net/p/htmlunit/bugs/

To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/htmlunit/admin/bugs/options.  Or, if this is a mailing list, you can unsubscribe from the mailing list.
--===============4286004074743566203==
MIME-Version: 1.0
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<div class="markdown_content"><ul>
<li><strong>status</strong>: pending --&gt; closed</li>
</ul>
<hr/>
<p><strong> <a class="alink strikethrough" href="https://sourceforge.net/p/htmlunit/bugs/1962/">[bugs:#1962]</a> FormSubmission not working - for log in</strong></p>
<p><strong>Status:</strong> closed<br/>
<strong>Group:</strong> 2.30<br/>
<strong>Labels:</strong> input form submission <br/>
<strong>Created:</strong> Fri May 11, 2018 04:13 PM UTC by Flake<br/>
<strong>Last Updated:</strong> Sun Feb 24, 2019 06:00 PM UTC<br/>
<strong>Owner:</strong> RBRi</p>
<p>I cannot get form submission to work on a login form. I've wasted hours and tried everything but there's no improvement whatsoever.</p>
<p>I've successfully used form submission for a search field - that worked as expected.<br/>
But for the login form HtmlUnit just does not seem to POST at all. Or it does and I do not manage to get the correct page.</p>
<p>I correctly retrieve the form and input elements.<br/>
I've tried setting the inputs (HtmlTextInput and HtmlPasswordInput) via <code>type()</code>, <code>setValueAttribbute()</code> and <code>setNodeValue()</code>.<br/>
I've tried submitting the form via getting the correct submit element and calling <code>page = submit.click();</code>, calling <code>page = (HtmlPage) username.type('\n');</code> and same for the password field.<br/>
I've tried getting the correct page by assigning the return value from <code>click()</code>, <code>type()</code> and also via <code>webClient.getCurrentWindow().getEnclosedPage()</code>. I also checked all windows - there were two but the second didn't seem to have a page ...<br/>
I've also waited for ages via <code>waitForBackgroundJavaScript()</code> and the other one as well as <code>Thread.sleep()</code> and have also tried the <code>NicelyResynchronizingAjaxController</code>.<br/>
I've tried <code>webClient.getOptions().setRedirectEnabled(true)</code> and <code>getCache().setMaxSize(0)</code>;</p>
<p>The page I try to log in to is this: <a href="https://www.dtad.de" rel="nofollow">https://www.dtad.de</a></p>
<p>When output the page I can see that the URL is still the root URL and that the input fields have the values that I set. So either the page wasn't submitted or I'm on the wrong page. The form action is what it's supposed to be (...validate.do). But here comes the even weirder thing:</p>
<p>When I try to log in via <a href="https://www.dtad.de/login" rel="nofollow">https://www.dtad.de/login</a> I get the bad credentials message after form submit. So submission seems to work. But when I log in via the root page I should be forwarded to <a href="https://www.dtad.de/login" rel="nofollow">https://www.dtad.de/login</a> (when entering bad credentials) but that does NOT happen. <code>page.asXml()</code> outputs the exact root page but with the input values set.</p>
<p>I'm really deperate and exhausted. I hope you can spot the mistake.<br/>
I've also checked if http -&gt; https makes a difference but it ain't.</p>
<p>Best,<br/>
Flake</p>
<hr/>
<p>Sent from sourceforge.net because [email protected] is subscribed to <a href="https://sourceforge.net/p/htmlunit/bugs/">https://sourceforge.net/p/htmlunit/bugs/</a></p>
<p>To unsubscribe from further messages, a project admin can change settings at <a href="https://sourceforge.net/p/htmlunit/admin/bugs/options.">https://sourceforge.net/p/htmlunit/admin/bugs/options.</a>  Or, if this is a mailing list, you can unsubscribe from the mailing list.</p></div>
--===============4286004074743566203==--
--===============2396990411513850537==--


--===============8950395393376733491==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============8950395393376733491==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop

--===============8950395393376733491==--