def test_04_get_text(self): # OCR on iOS 13 text = ImageUtils.get_text(self.app_image_default_ios) assert 'taps left' in text assert 'Tap the button' in text assert 'TAP' in text # OCR on Hello-World app text = ImageUtils.get_text(self.app_image_ios) assert 'My App' in text assert 'Tap the button' in text assert 'HIT' in text assert '42 clicks left' in text # OCR on Hello-World app text = ImageUtils.get_text(self.app_image) assert 'My App' in text assert 'Tap the button' in text assert 'TAP' in text assert '42 taps left' in text # OCR on complex screen (iPhone home screen). text = ImageUtils.get_text(self.iphone_image) assert 'Monday' in text assert 'Reminders' in text assert 'Settings' in text
def test_05_get_text_unicode(self): text = ImageUtils.get_text(self.unicode_image) Log.info(text) assert 'Ter Stegen' in text assert 'Neymar' in text text = ImageUtils.get_text(self.app_image_ng) Log.info(text) assert 'Ter Stegen' in text assert 'Piqué' in text
def get_text(self): img_name = "actual_{0}_{1}.png".format(self.id, time.time()) actual_image_path = os.path.join(Settings.TEST_OUT_IMAGES, img_name) File.delete(actual_image_path) self.get_screen(path=actual_image_path, log_level=logging.DEBUG) text = ImageUtils.get_text(image_path=actual_image_path) File.delete(path=actual_image_path) return text
def get_screen_text(): """ Get text of current screen of host machine. :return: All the text visible on screen as string """ actual_image_path = os.path.join(Settings.TEST_OUT_IMAGES, "host_{0}.png".format(time.time())) if File.exists(actual_image_path): File.delete(actual_image_path) Screen.save_screen(path=actual_image_path) text = ImageUtils.get_text(image_path=actual_image_path) File.delete(actual_image_path) return text