Regular Expression for value of the money (Java)

Do you have to catch only the value of some value of money ?

Use this simple expression, just change the value R$ for the correct money that you need take out.

String preco = precoatual.getText();

String replace = “”;
Pattern pattern = Pattern.compile(“[^0-9&&[R$]]”);
Matcher matcher = pattern.matcher(preco);
preco = matcher.replaceAll(replace);

And if the value is: R$ 124,28 – The result will are: 124,28

Simple don’t ?

Bye bye !

Mouse up of a WebElement (Selenium and Java)

Move the mouse up of a controller/WebElement is simple, is just put this line of code:

WebElement valoratual = driver.findElement(By.className(“product-description-catalog-item”));

Robot robot = new Robot();
robot.mouseMove(valoratual.getLocation().getX(), valoratual.getLocation().getY());

 

Yes, you have to catch the X and Y in the page and the robot will put the mouse over thispoint.

 

Bye bye 🙂