Created
August 21, 2017 16:46
-
-
Save samlucax/255ebc94b6f3361b4d8c81b63a70d612 to your computer and use it in GitHub Desktop.
Automatizando validação de códigos de barras com API Zxing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); | |
BufferedImage imagem = ImageIO.read(screenshot); | |
//Se você prefere uma imagem só do trecho onde o código de barras aparece, pode realizar um corte na imagem, da seguinte forma: | |
//Pegando a posicao do elemento | |
Point posicao = codigoDeBarras.getLocation(); | |
//Pegando altura e largura do elemento | |
int larguraElemento = codigoDeBarras.getSize().getWidth();int alturaElemento = codigoDeBarras.getSize().getHeight(); | |
//Recortando a imagem | |
BufferedImage imagemCortada = imagem.getSubImage(point.getX(), point.getY(), eleWidth, eleHeight); | |
ImageIO.write(imagemCortada, "jpg", imagem); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment