This project shows how to read the QRCode content from a webapp using Selenium and ZXing.
- Java as the programming language
- Selenium as the web test automation tool
- Zxing as the library to decode the QRCode content
- AssertJ as the assertion library
- JUnit 5 as the test tool to support the test automation script
- WebDriverManager as the browser binary management library
- Java JDK >=11
- Google Chrome installed
- Go do the project directory and run
mvn verify -Dmaven.test.skip=true
- Run
mvn test
to run the test
- Open this project in your preferred IDE
- Open the
QRCodeTest
class placed insrc/test/java
- Run the test
You can expect a successful execution. The test will read the QRCode content and assert by its expectation.
- Open the browser in a page that has a QRCode
- In the test that reads the image src as path
readQRCodeFromURL
- Get the image path and transform it in a
BufferedImage
- Get the image path and transform it in a
- In the test that reads the image src as Base64
readQRCodeFromBase64
- Get the Base64 content and transform it in a
BufferedImage
- Get the Base64 content and transform it in a
- Process the image and decode it using ZXing
- Return the QRCode content
- Assert the QRCode content