1

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:

  • mac os
  • selenium-java-3
  • guava-25.0-jre
  • java 8
  • Google Chrome 77 version
  • ChromeDriver 77.0.3865.40

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.