[HtmlUnit] [htmlunit:bugs] #1962 FormSubmission not working - for log in
RBRi via HtmlUnit-develop <[email protected]>
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1962/98a700e83d26cc2a652e6a140cbc7cd7ebb50b99.bugs@htmlunit.p.sourceforge.net> |
Hi Flake,
finally found some time to work on this.
HtmlUnit always checks if a control is 'visible' before the interaction can take place. This was introduced some versions ago. As a result of this you have to move the mouse over the Login text before you can fill the form.
~~~
HtmlAnchor anchor = page.getAnchorByText("Login");
HtmlListItem listItem = (HtmlListItem) anchor.getParentNode().getParentNode();
listItem.mouseOver();
~~~
After this you can interact with the controls (use type() to fill the entry fields and click() for the sumbit)
Now the tricky part, there was a small bug in HtmlUnit, the login form was still not visible after the mouse over. The reason was a wrong specificity calculation for the :hover style that leads to ignoring this style in the end.
This is now fixed in the htmlunit-cssparser and for me it looks like the page is no working.
Please have a look (and thanks for this challenge :-)
Just made a new snapshot build available for testing.
---
** [bugs:#1962] FormSubmission not working - for log in**
**Status:** accepted
**Group:** 2.30
**Labels:** input form submission
**Created:** Fri May 11, 2018 04:13 PM UTC by Flake
**Last Updated:** Mon May 14, 2018 08:55 AM 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.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop