[PYTHON] (Test automation) Nesting images used for image recognition

background

We are building and operating a test automation system for in-house system developers. (SikuliX + Testablish) Write down the technical issues and things you want to do on a daily basis.

Sikuli is fun!

Task

As with most RPA tools, operation scenarios are closed in a single file. What is worrisome about it is that it is a pity that the image is included in the scenario. Images change with minor specification changes, so I think it's important to make the images so that they can be easily replaced. So, I tried to make it so that the image in the operation scenario of Sikuli can be pulled from the separately built Web Service.

Correspondence

The image file part in the operation scenario of Sikuli is pulled from Web Service.

Purpose

I want to be able to reuse images by replacing images in a single scenario such as file upload, download, and Excel operation on each system.

Contents

There was one issue in implementation. That's the point that sikulix thinks it's python and needs to be implemented in jython. jython is a python language that runs on the JVM, and it seems that it sells a small amount of coding and simplicity, but I feel that the small amount of information on the WEB is a bottleneck. https://www.jython.org/

However, the new language I learn (well, it's a child of python and java) is exciting, so let's try it.

Verify with the following implementation and succeed.

----------------------- import java.net.HttpURLConnection import java.net.URL import java.io.BufferedReader import java.io.InputStreamReader import java.lang.StringBuffer import json import base64 import datetime

URL = java.net.URL url = 'RESTURL' obj = URL(url) con = obj.openConnection() con.setRequestMethod("GET") responseCode = con.getResponseCode()

BufferedReader = java.io.BufferedReader InputStreamReader = java.io.InputStreamReader

buf = BufferedReader(InputStreamReader(con.getInputStream())) response = buf.readLine() buf.close();

dir = os.getcwd()

Image is Base64 and ascii, REST return value is json file

Decode on jython

downloadData = json.loads(response) fileName = downloadData['fileName'] contentType = downloadData['contentType'] contentDataAscii = downloadData['contentData'] now = datetime.datetime.now().strftime("%Y%m%d%H%M%S") contentData = base64.b64decode(contentDataAscii) saveFileName = now + fileName saveFilePath = os.path.join(dir, saveFileName) with open(saveFilePath, 'wb') as saveFile:  saveFile.write(contentData)

↓ ↓ Image recognition processing ↓ ↓ -----------------------

Result or what you noticed

An image that imports the java library on python and describes java and gorigori. As long as you know the import specification format and instance creation method, the rest is smooth.

Conclusion

This will promote standardization of operation scenarios!

Recommended Posts

(Test automation) Nesting images used for image recognition
(Test automation) Make image recognition ambiguous
Test automation for work
Image recognition
Read & implement Deep Residual Learning for Image Recognition
Basic principles of image recognition technology (for beginners)
Implementation of Deep Learning model for image recognition
Create an environment for test automation with AirtestIDE (Tips)