Reputation: 1912
I need to enter my numeric value in input with currency. The field has a default attribute of 0.00.
this command does not change anything:
webElement.clear();
System.out.println("webElement.getAttribute("value")); //0,00
When I try to register my value equal to 803 in it, the field eventually gets a value of 0.00803, which is then rounded to 0.01:
webElement.sendKeys(text);
System.out.println("webElement.getAttribute("value")); //0,008003
The same thing happens when I use this command:
webElement.sendKeys(Keys.chord(Keys.COMMAND, "a", text)); //0,008003
Environment:
Upvotes: 1
Views: 265
Reputation: 17553
You can use executeScript()
method from JavascriptExecutor
as below :
WebElement element = driver.findElement(By.xpath("enter the xpath here")); // you can use any locator
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("arguments[0].value='enter the value here';", element);
Upvotes: 2