get the decode value of QR code using Appium and postman

431 views Asked by At

I have created a session and located the QR code element ID using endpoint mentioned in Appium documentation. enter image description here

This is the value of text I'm getting from QR code; I expect the actual decode of QR code which can be further used in applications for automation. I was wondering if other application needs to be used or it is possible in postman itself.

2

There are 2 answers

6
Dima Berezovskyi On

Well, in fact, there are several questions here, is the QR code value static or dynamic, that is, does the QR code change during each test or can you use the same QR for all tests

If the value does not change(static), you can create a file, say .yaml, in the resources or test data directory, where your value will be stored in an encoded form, then you read this value from the file, decode it and pass it to the test script

If the QR code changes(dynamic value) for each test, you can create an API call, for python you can use the requests library or Java RestAssured, you take the encoded value from the response, decode it and pass it to the test script

the implementation depends on the above, but the whole process must be implemented within your framework

So you don't need to use additional tools like Postman etc to get value and decode it, if you want to automate your case properly combine API and UI

To decode value in Python I use Fernet, Java bouncycastle

1
sr freak On

The issue was solved by using python's cv2 library

filename = "img.png"
# read the QRCODE image
image = cv2.imread(filename)
# initialize the cv2 QRCode detector
detector = cv2.QRCodeDetector()
# detect and decode
data, vertices_array, binary_qrcode = detector.detectAndDecode(image)
if vertices_array is not None:
print("QRCode data:")
print(data)
else:
    print("There was some error")