def get_text(self, *regions): # type: (*OCRRegion) -> List[Text] result = [] for ocr_region in regions: self._process_app_output(ocr_region) image = ocr_region.app_output_with_screenshot.screenshot.image screenshot_url = self._server_connector.try_upload_image( image_utils.get_bytes(image)) data = TextSettingsData( app_output=AppOutput( screenshot_url=screenshot_url, location=Point.ZERO(), dom_url=ocr_region.app_output_with_screenshot.app_output. dom_url, ), language=ocr_region._language, min_match=ocr_region._min_match, regions=[ ExpectedTextRegion( 0, 0, width=image.width, height=image.height, expected=ocr_region._hint, ) ], ) result.extend( self._server_connector.get_text_in_running_session_image(data)) return result
def _match_window(self, region_provider, tag, ignore_mismatch, check_settings): # type: (RegionProvider, Text, bool, SeleniumCheckSettings) -> MatchResult # Update retry timeout if it wasn't specified. retry_timeout_ms = -1 # type: int if check_settings: retry_timeout_ms = check_settings.values.timeout check_settings = self._process_check_settings_values(check_settings) region = region_provider.get_region() logger.debug("params: ([{}], {}, {} ms)".format( region, tag, retry_timeout_ms)) app_output = AppOutput( title=tag, screenshot64=None, screenshot_url=self.render_status.image_location, dom_url=self.render_status.dom_location, ) result = self._match_window_task.perform_match( app_output=AppOutputWithScreenshot(app_output, None), name=tag, ignore_mismatch=ignore_mismatch, image_match_settings=ImageMatchSettings.create_from_check_settings( check_settings), eyes=self, user_inputs=self._user_inputs, check_settings=check_settings, render_id=self.render_status.render_id, region_selectors=self._region_selectors, regions=self._regions, ) return result
def _get_app_output_with_screenshot(self, region, last_screenshot, check_settings): # type: (None, None, SeleniumCheckSettings)->AppOutputWithScreenshot logger.debug("render_task.uuid: {}".format(self._current_uuid)) app_output = AppOutput( title=self._title, screenshot_bytes=None, screenshot_url=self.render_status.image_location, dom_url=self.render_status.dom_location, ) result = AppOutputWithScreenshot(app_output, None) return result
def get_app_output(): scale_provider = self._eyes.update_scaling_params() viewport_screenshot = self._eyes.get_scaled_cropped_viewport_image( scale_provider) image = image_utils.get_bytes(viewport_screenshot) screenshot_url = self._server_connector.try_upload_image(image) dom_json = self._eyes._try_capture_dom() dom_url = self._eyes._try_post_dom_capture(dom_json) return AppOutput(dom_url=dom_url, screenshot_url=screenshot_url, location=Point.ZERO())
def test_multithreading_serialization(i): mwd = MatchWindowData( agent_setup=None, app_output=AppOutput( dom_url="https://eyespublicwusi0.core/bl9crP4n81pwT9anq3r1Xr8g0e97eMliN8f7etrM110", screenshot_url="https://eyespublicwusi0.blob.core/g0e97eMliN8f7etrM110", viewport=RectangleSize(height=1300, width=2560), title="", screenshot_bytes=None, ), ignore_mismatch=False, user_inputs=[], tag="Capture", render_id="bf3ce18291b4aa933bee", options=Options( force_match=False, force_mismatch=False, ignore_mismatch=False, ignore_match=False, image_match_settings=ImageMatchSettings( ignore_regions=[ Region(height=41, left=30, top=165, width=738), Region(height=32, left=30, top=480, width=738), ] ), name="Capture", render_id="bf3ce18291b4aa933bee", replace_last=False, source="applitoolscasppe.cm", user_inputs=[], ), ) with ThreadPoolExecutor() as executor: results = list(executor.map(json_utils.to_json, [mwd] * 100)) assert len(results) == 100 for i, r in enumerate(results): assert "Ignore" in r assert "ignoreRegions" not in r
def _get_app_output_with_screenshot(self, region, last_screenshot, check_settings): # type: (Region, EyesScreenshot, CheckSettings) -> AppOutputWithScreenshot logger.info("getting screenshot...") screenshot = self._get_screenshot() logger.info("Done getting screenshot!") if not region.is_size_empty: screenshot = screenshot.sub_screenshot(region) self._debug_screenshot_provider.save(screenshot.image, "sub_screenshot") if not self._dom_url and ( self.configuration.send_dom or check_settings.values.send_dom ): dom_json = self._try_capture_dom() self._dom_url = self._try_post_dom_snapshot(dom_json) logger.info("dom_url: {}".format(self._dom_url)) app_output = AppOutput( title=self._title, screenshot64=None, dom_url=self._dom_url ) result = AppOutputWithScreenshot(app_output, screenshot) logger.info("Done") return result
"matches": 1, "mismatches": 0, "missing": 0, "exactMatches": null, "strictMatches": null, "contentMatches": null, "layoutMatches": null, "noneMatches": null, "status": "Passed" }""" STOP_SESSION_OBJ = attr_from_json(STOP_SESSION_DATA, TestResults) MATCH_WINDOW_DATA_OBJ = MatchWindowData( ignore_mismatch=False, user_inputs=[], app_output=AppOutput(title="Title", screenshot_bytes=None, screenshot_url="http"), tag="Tag", options=Options( name="Opt name", user_inputs=[], ignore_mismatch=False, ignore_match=False, force_match=False, force_mismatch=False, image_match_settings=SESSION_START_INFO_OBJ.default_match_settings, render_id=None, ), agent_setup="Agent setup", render_id=None, ) IMAGE_BASE_64 = "iVBORw0KGgoAAAANSUhEUgAAAlgAAAJYCAYAAAC+ZpjcAAAFi0lEQVR4nO3BAQ0AAADCoPdPbQ43oAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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