How to use test_screenshot method in ATX

Best Python code snippet using ATX

Testing.py

Source:Testing.py Github

copy

Full Screen

1"""2Need testing.3"""4# Handle imports5import unittest6from LoadTilesets import image_to_array, get_tileset_by_id, get_id_of_tileset, get_tileset7from Convert import detect_tileset, check_tileset_all_offsets, get_tile_ids8import numpy as np9import json10import os11# Define constants12test_screenshots = [os.path.join("resources", "screenshots", "Image_Vidumec15x15b.png"),13 os.path.join("resources", "screenshots", "Image_Anikki8x8.png")]14actual_tileset_names = ["Vidumec", "Anikki_square_8x8"]15actual_offsets = [(9, 12), (6, 4)]16actual_tile_id_files = [os.path.join("resources", "test", "Image_Vidumec15x15b_tile_ids"),17 os.path.join("resources", "test", "Image_Anikki8x8_tile_ids")]18# Setup19# Define methods20class TestLoadTilesetMethods(unittest.TestCase):21 def test_image_to_array(self):22 tileset = image_to_array("resources/test/Curses 640x300diag.png")23 assert (tileset == np.load("resources/test/Curses.npy")).all()24class TestConvertMethods(unittest.TestCase):25 def test_detect_tileset0(self):26 self.general_test_tileset(0)27 def test_detect_tileset1(self):28 self.general_test_tileset(1)29 def general_test_tileset(self, i):30 global test_screenshots, actual_tileset_names, actual_offsets31 test_screenshot = test_screenshots[i]32 actual_tileset_name = actual_tileset_names[i]33 actual_offset = actual_offsets[i]34 image = image_to_array(test_screenshot)[:,:,:3]35 tileset_id, offset = detect_tileset(image)36 assert (tileset_id == get_id_of_tileset(actual_tileset_name)), "Detected tileset id: {}, name: {}".format(tileset_id, get_tileset_by_id(tileset_id)["local_filename"])37 assert (tuple(offset) == actual_offset), "Detected offset: {}".format(offset)38 def test_check_tileset_all_offsets0(self):39 self.general_test_check_tileset_all_offsets(0)40 def test_check_tileset_all_offsets1(self):41 self.general_test_check_tileset_all_offsets(1)42 def general_test_check_tileset_all_offsets(self, i):43 global test_screenshots, actual_tileset_names, actual_offsets44 actual_tileset_name = actual_tileset_names[i]45 actual_tileset = get_tileset(actual_tileset_name)46 actual_offset = actual_offsets[i]47 test_screenshot = test_screenshots[i]48 image = image_to_array(test_screenshot)[:, :, :3]49 subset = image[50 0: 4 * actual_tileset["shape"][0],51 0: 4 * actual_tileset["shape"][1],52 ]53 _, offset = check_tileset_all_offsets(subset, actual_tileset, [3, 3])54 assert (offset == actual_offset), "Detected offset: {}".format(offset)55 def test_get_tile_ids0(self):56 self.general_test_get_tile_ids(0)57 def test_get_tile_ids1(self):58 self.general_test_get_tile_ids(1)59 def general_test_get_tile_ids(self, i):60 global test_screenshots, actual_tileset_names, actual_offsets, actual_tile_id_files61 actual_tileset_name = actual_tileset_names[i]62 actual_tileset = get_tileset(actual_tileset_name)63 actual_offset = actual_offsets[i]64 with open(actual_tile_id_files[i], "r") as f:65 actual_tile_ids = json.loads(f.read())66 test_screenshot = test_screenshots[i]67 image = image_to_array(test_screenshot)[:, :, :3]68 cropped_image = image[actual_offset[0]:,actual_offset[1]:]69 tile_ids = get_tile_ids(cropped_image, actual_tileset)...

Full Screen

Full Screen

test_screenshot.py

Source:test_screenshot.py Github

copy

Full Screen

1# 좌표 최적화를 위해 스크린샷을 찍습니다.2import pyautogui3import time4import os5from datetime import datetime6file_name = datetime.now().strftime("%Y-%m-%d %H-%M-%S")7if not os.path.isdir("test_screenshot"):8 os.mkdir("./test_screenshot")9time.sleep(3)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ATX automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful