Skip to content

HtmlNumberInput Not Accepting decimals #123

@Athas1980

Description

@Athas1980

#Summary

#Example
Given the following

<html><head><title>testcase</title></head>
<body>
<input type="number" step="0.01" value="0.00" id="decimalField" value="decimalField" />
</body>
</html>

You are unable to set the value of the HtmlNumberInput to set the value to a decimal value.

htmlPage.getElementByName<htmlNumberInput>("decimalField").setValue("0.5");
assertThat(htmlPage.getElementByName<htmlNumberInput>("decimalField").getValue()).isEqualTo("0.5"); // returns 0

This appears to be due to the fact that HtmlNumberInput tries to parse the value as a Long and long doesn't accept decimal values.

#Workarounds
calling setAttributeNs(null, "value", "0.5") works correctly.

#Possible Solutions

  1. Ignore the value validation completely.
  2. Try to parse the value as a BigDecimal
  3. Try to parse the value as a Double.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions