[HtmlUnit] [htmlunit:bugs] Re: #1992 Error in validation of required fields
RBRi via HtmlUnit-develop <[email protected]> Thu, 11 Oct 2018 06:10:36 -0000
| Newsgroups | gmane.comp.java.htmlunit.devel |
|---|---|
| Message-ID | </p/htmlunit/bugs/1992/bff8075f93071f9100662452f0a13ba5ea592eb6.bugs@htmlunit.p.sourceforge.net> |
> Thanks a lot for your time and effort
You are welcome
> As I can see from your examples, the form should never submit
if it contains an input
> changed between releases
The idea of HtmlUnit is to mimic the supported browsers as close as possible. Therefor we write most of our unit test in a way to be able to execute the tests with real browsers (selenium) to figure out what the expected results are and later on we can run the same suite with HtmlUnit to proove the simulation works.
The test for required where missing so far, so writing this had to be done anyway.
Summary: if you find a case where the HtmlUnit result/behaviour is different from the real browser then you found a bug
> could emit a warning similar
Good suggestion will add this later today and make a new snapshot build available
---
** [bugs:#1992] Error in validation of required fields**
**Status:** pending
**Group:** 2.33
**Created:** Wed Oct 10, 2018 03:00 PM UTC by Leonardo Silva Medina
**Last Updated:** Wed Oct 10, 2018 07:56 PM UTC
**Owner:** RBRi
Hi !!
I try to perform a test on a form and when clicking I do not do any event, the form has an elment of
<input type="text" id="idUserRecupera" class="autoMayuscula sinTildes" autocomplete="off" required="">
to appear in the class
/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java => method
public boolean isValid() {
return !isRequiredSupported() || getAttributeDirect("required") == ATTRIBUTE_NOT_DEFINED
|| !getAttributeDirect("value").isEmpty();
}
there is a method that validates the required fields, and I note that it has three validation criteria with a conditional || ( OR ), following the code for my case the condition (getAttributeDirect ("required") == ATTRIBUTE_NOT_DEFINED) this returns as FALSE result, but observed in more detail I see that it should be true since,
getAttributeDirect ("required") = ""
ATTRIBUTE_NOT_DEFINED = "",
change it to
getAttributeDirect ("required"). equals (ATTRIBUTE_NOT_DEFINED)
and return the result that should be TRUE, in my opinion it is the indicated comparison to determine if the values are the same.
public boolean isValid() {
return !isRequiredSupported() || getAttributeDirect ("required"). equals (ATTRIBUTE_NOT_DEFINED)
|| !getAttributeDirect("value").isEmpty();
}
---
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.
_______________________________________________
HtmlUnit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop