def get_image(self): # type: () -> Image logger.debug("Getting screenshot as base64...") screenshot64 = self._eyes.driver.get_screenshot_as_base64() logger.debug("Done getting base64! Creating BufferedImage...") image = image_utils.image_from_base64(screenshot64) self._eyes.debug_screenshots_provider.save(image, "initial") return image
def get_screenshot_as_base64(self): # type: () -> Text """ Gets the screenshot of the current window as a base64 encoded string which is useful in embedded images in HTML. """ screenshot64 = self._driver.get_screenshot_as_base64() screenshot = image_utils.image_from_base64(screenshot64) screenshot = self.normalize_rotation(self._driver, screenshot, self.rotation) screenshot64 = image_utils.get_base64(screenshot) return screenshot64
def prepare_match_data(match_data): # type: (MatchWindowData) -> bytes screenshot64 = match_data.app_output.screenshot64 if screenshot64: match_data.app_output.screenshot64 = None image = image_utils.image_from_base64(screenshot64) screenshot_bytes = image_utils.get_bytes(image) # type: bytes else: screenshot_bytes = b"" match_data_json = json_utils.to_json(match_data) logger.debug("MatchWindowData {}".format(match_data_json)) match_data_json_bytes = match_data_json.encode("utf-8") # type: bytes match_data_size_bytes = pack(">L", len(match_data_json_bytes)) # type: bytes body = match_data_size_bytes + match_data_json_bytes + screenshot_bytes return body
def get_image(self): driver = self._eyes.driver # type: EyesWebDriver fc = driver.frame_chain.clone() logger.debug("frameChain size: {}".format(fc.size)) logger.debug("Switching temporarily to default content.") driver.switch_to.default_content() logger.debug("Getting screenshot as base64.") screenshot64 = driver.get_screenshot_as_base64() logger.debug("Done getting base64! Creating BufferedImage...") image = image_utils.image_from_base64(screenshot64) logger.debug("Done. Switching back to original frame.") driver.switch_to.frames(fc) return image
def get_screenshot_as_base64(self): # type: () -> Text """ Gets the screenshot of the current window as a base64 encoded string which is useful in embedded images in HTML. """ screenshot64 = self._driver.get_screenshot_as_base64() display_rotation = self.get_display_rotation() if display_rotation != 0: logger.info("Rotation required.") # num_quadrants = int(-(display_rotation / 90)) logger.debug("Done! Creating image object...") screenshot = image_utils.image_from_base64(screenshot64) # rotating if display_rotation == -90: screenshot64 = image_utils.get_base64(screenshot.rotate(90)) logger.debug("Done! Rotating...") return screenshot64
def test_match_window_with_image_uploading(started_connector, server_status): # type: (ServerConnector, int) -> None data = copy(MATCH_WINDOW_DATA_OBJ) data.app_output.screenshot_url = None data.app_output.screenshot_bytes = image_utils.get_bytes( image_utils.image_from_base64(IMAGE_BASE_64)) rendering_info = RenderingInfo( access_token="some access", service_url="https://render-wus.applitools.com", results_url= "https://eyespublicwustemp.blob.core.windows.net/temp/__random__?sv=2017-04-17&sr=c&sig=aAArw3au%", stitching_service_url="https://some.stitchingserviceuri.com", ) with patch( "applitools.core.server_connector.ServerConnector.render_info", return_value=rendering_info, ): with patch( "applitools.core.server_connector.ClientSession.put", return_value=MockResponse(None, None, server_status), ): with patch( "applitools.core.server_connector.ClientSession.post", side_effect=mocked_requests_post, ): if server_status in [200, 201]: started_connector.match_window(RUNNING_SESSION_OBJ, data) else: with pytest.raises(EyesError): started_connector.match_window(RUNNING_SESSION_OBJ, data) if server_status in [200, 201]: target_url = data.app_output.screenshot_url assert target_url.startswith( "https://eyespublicwustemp.blob.core.windows.net/temp/") assert target_url.endswith("?sv=2017-04-17&sr=c&sig=aAArw3au%") assert "__random__" not in target_url
def get_image(self): # type: () -> Image logger.info("Getting screenshot as base64...") screenshot64 = self._eyes.driver.get_screenshot_as_base64() logger.info("Done getting base64! Creating BufferedImage...") return image_utils.image_from_base64(screenshot64)