Athas1980 · GitHub

#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.

Read the original on github.com ↗